Let’s say I have a Model named: Psdump.php and it is found in /models/Psdump.php
< ?php /** * Psdump.php * /opt/apache2/htdocs/apps/org_v2/application/models/Psdump.php */ require_once APPLICATION_PATH.'/models/PsdumpTable.php'; //I will need this class Psdump extends Zend_Db_Table { protected $_table; public function getTable() { if(null === $this->_table) { $this->_table = new PsdumpTable; } return $this->_table; } public function fetchAllEmployees() { return $this->getTable()->fetchActiveEmployees(); } } |
And for the “extension”…
< ?php /** * PsdumpTable * /opt/apache2/htdocs/apps/org_v2/application/models/PsdumpTable.php * */ class PsdumpTable extends Zend_Db_Table_Abstract { protected $_name = 'psdump'; public function insert(array $data) { return parent::insert($data); } public function fetchActiveEmployees() { $sql = "SELECT * FROM ".$this->_name." WHERE Status=".$this->_db->quote('A'); return $this->_db->fetchAll($sql); } } |
Even though I will have more files — the end result is that this Model setup will be easier to maintain and understand.
Hehe, another post that only I can understand