Model.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 dirname(__FILE__) . '/DataAccess.php';
00026 
00027 // }}}
00028 // {{{ class FF_Model 
00029 
00043 // }}}
00044 class FF_Model {
00045     // {{{ properties
00046 
00051     var $o_dataAccess;
00052 
00057     var $id;
00058 
00059     // }}}
00060     // {{{ constructor
00061 
00068     function FF_Model()
00069     {
00070         $this->_initDataAccess();
00071     }
00072 
00073     // }}}
00074     // {{{ reset()
00075 
00082     function reset()
00083     {
00084         // interface
00085     }
00086 
00087     // }}}
00088     // {{{ remove()
00089 
00099     function remove($in_id = null)
00100     {
00101         $s_id = is_null($in_id) ? $this->getId() : $in_id;
00102         return $this->o_dataAccess->remove($s_id);
00103     }
00104 
00105     // }}}
00106     // {{{ save()
00107 
00116     function save($in_isUpdate)
00117     {
00118         if ($in_isUpdate) {
00119             return $this->o_dataAccess->update($this->exportToArray());
00120         }
00121         else { 
00122             $this->setId($this->o_dataAccess->getNextId());
00123             return $this->o_dataAccess->add($this->exportToArray());
00124         }
00125     }
00126 
00127     // }}}
00128     // {{{ importFromArray()
00129 
00139     function importFromArray($in_data)
00140     {
00141         // interface
00142     }
00143 
00144     // }}}
00145     // {{{ exportToArray()
00146 
00155     function exportToArray()
00156     {
00157         // interface
00158     }
00159 
00160     // }}}
00161     // {{{ fillById()
00162 
00171     function fillById($in_id)
00172     {
00173         $this->reset();
00174         $a_data = $this->o_dataAccess->getDataByPrimaryKey($in_id);
00175         if (count($a_data) == 0) {
00176             return false;
00177         }
00178         else {
00179             $this->importFromArray($a_data);
00180             return true;
00181         }
00182     }
00183 
00184     // }}}
00185     // {{{ getId()
00186 
00193     function getId()
00194     {
00195         return $this->id;
00196     }
00197     
00198     // }}}
00199     // {{{ setId()
00200 
00209     function setId($in_id)
00210     {
00211         $this->id = $in_id;
00212     }
00213     
00214     // }}}
00215     // {{{ getDataAccessObject()
00216 
00223     function &getDataAccessObject()
00224     {
00225         return $this->o_dataAccess;
00226     }
00227 
00228     // }}}
00229     // {{{ _scalarToBool()
00230 
00239     function _scalarToBool($in_value)
00240     {
00241         if (!is_bool($in_value)) {
00242             return ($in_value == 'T' || $in_value == 1) ? true : false;
00243         }
00244         else {
00245             return $in_value;
00246         }
00247     }
00248 
00249     // }}}
00250     // {{{ _initDataAccess()
00251 
00258     function _initDataAccess()
00259     {
00260         // interface
00261     }
00262 
00263     // }}}
00264 }
00265 ?>

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