DataAccess/mysql/CustomField.php

Go to the documentation of this file.
00001 <?php
00003 // {{{ license
00004 
00005 // +----------------------------------------------------------------------+
00006 // | FastFrame Application Framework                                      |
00007 // +----------------------------------------------------------------------+
00008 // | Copyright (c) 2002-2006 The Codejanitor Group                        |
00009 // +----------------------------------------------------------------------+
00010 // | This source file is subject to the GNU Lesser Public License (LGPL), |
00011 // | that is bundled with this package in the file LICENSE, and is        |
00012 // | available at through the world-wide-web at                           |
00013 // | http://www.fsf.org/copyleft/lesser.html                              |
00014 // | If you did not receive a copy of the LGPL and are unable to          |
00015 // | obtain it through the world-wide-web, you can get it by writing the  |
00016 // | Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
00017 // | MA 02111-1307, USA.                                                  |
00018 // +----------------------------------------------------------------------+
00019 // | Authors: Jason Rust <jrust@codejanitor.com>                          |
00020 // +----------------------------------------------------------------------+
00021 
00022 // }}}
00023 // {{{ requires
00024 
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/DataAccess.php';
00026 
00027 // }}}
00028 // {{{ class FF_DataAccess_CustomField_mysql 
00029 
00040 // }}}
00041 class FF_DataAccess_CustomField_mysql extends FF_DataAccess {
00042     // {{{ properties
00043 
00048     var $dataTable;
00049 
00050     // }}}
00051     // {{{ constructor
00052 
00059     function FF_DataAccess_CustomField_mysql()
00060     {
00061         FF_DataAccess::FF_DataAccess();
00062         $this->table = $this->o_registry->getConfigParam('data/custom_fields', 'mayday_custom_fields', 'mayday');
00063         $this->dataTable = $this->o_registry->getConfigParam('data/custom_fields_data', 'mayday_custom_fields_data', 'mayday');
00064     }
00065 
00066     // }}}
00067     // {{{ remove()
00068 
00077     function remove($in_id)
00078     {
00079         $o_result =& parent::remove($in_id); 
00080         if ($o_result->isSuccess()) {
00081             $tmp = $this->table;
00082             $this->table = $this->dataTable;
00083             $o_result =& parent::remove($in_id, 'field_id');
00084             $this->table = $tmp;
00085         }
00086         
00087         return $o_result;
00088     }
00089 
00090     // }}}
00091     // {{{ getFieldsByCategory()
00092 
00103     function getFieldsByCategory($in_catId, $in_ticketId = null)
00104     {
00105         if (!is_null($in_ticketId)) {
00106             $s_query = "SELECT id, category_id, description, type, data
00107                         FROM $this->table AS t1 
00108                         LEFT JOIN $this->dataTable AS t2 ON t1.id = t2.field_id AND ticket_id = ?
00109                         WHERE category_id = ? ORDER BY id";
00110 
00111             return $this->o_data->getAll($s_query, array($in_ticketId, $in_catId));
00112         }
00113         else {
00114             $s_query = "SELECT * FROM $this->table WHERE category_id = ? ORDER BY id";
00115 
00116             return $this->o_data->getAll($s_query, array($in_catId));
00117         }
00118 
00119     }
00120 
00121     // }}}
00122     // {{{ saveData()
00123 
00135     function saveData($in_fieldId, $in_ticketId, $in_data, &$in_result)
00136     {
00137         $result = $this->o_data->autoExecute($this->dataTable, array('data' => $in_data, 'field_id' => $in_fieldId, 'ticket_id' => $in_ticketId));
00138         if (DB::isError($result)) {
00139             $in_result->addMessage($result->getMessage());
00140         }
00141     }
00142 
00143     // }}}
00144     // {{{ removeDataForTicket()
00145 
00154     function removeDataForTicket($in_ticketId)
00155     {
00156         $s_stmt = $this->o_data->prepare("DELETE FROM $this->dataTable WHERE ticket_id = ?");
00157         $this->o_data->execute($s_stmt, $in_ticketId);
00158     }
00159 
00160     // }}}
00161     // {{{ getCategoriesWithField()
00162 
00169     function getCategoriesWithField()
00170     {
00171         $s_query = "SELECT DISTINCT(category_id) FROM $this->table";
00172         return $this->o_data->getCol($s_query, 0);
00173     }
00174 
00175     // }}}
00176     // {{{ getNextId()
00177 
00184     function getNextId()
00185     {
00186         // change sequence name since we give it the full table name
00187         $this->o_data->setOption('seqname_format', '%s');
00188         return $this->o_data->nextId($this->o_registry->getConfigParam('data/sequence_table'));
00189     }
00190 
00191     // }}}
00192 }
00193 ?>

Generated on Fri Jun 23 11:38:15 2006 for FastFrame by  doxygen 1.4.4