nadeemshafi9 Posted July 14, 2009 Share Posted July 14, 2009 hello guys i am trying to extend a method of a class but i am getting ERROR: declaration of Model Db Cluster::update() should be compatible with that of Zend_Db_Table_Abstract::update() in <b>/var/websites/irh.net/application/models/DbCluster.php i reflected the parent and made sure my signiture was correct <?php class Model_DbCluster extends Zend_Db_Table { /** Model_Table_Inventory * List your tables that this model can reference here... * */ protected $_table; protected $_name = 'hosts_inventory'; protected $_schema = 'irh_tftp'; // database name protected $_mode; public function getTable($name) { //add2debug("DBCLUSTER getTable called for [$name]"); $_name = $name; $_model = "table_$name"; //add2debug("NULL CHECK [this -> $_name]"); if (null === @$this->$_name) // supress the error if it doesnt exist yet { // since the dbTable is not a library item but an application item, // we must require it to use it require_once APPLICATION_PATH . "/models/DbTable/$name.php"; $this->$_name = new $_model; } return $this->$_name; } public function update($data , $where){ $r = parent::update(); $user = Zend_Registry::get('user'); $dbAdapters = Zend_Registry::get('dbAdapter'); $db = $dbAdapters['server1']; $model = $this->_getModel(); $irh_user_transactions = $model->getTable("irh_user_transactions"); $profiler = $db->getProfiler(); $profile = $profiler->getLastQueryProfile(); $data = array( 'user_id' => $user->user_id, 'transaction' => $profile ); try{ $irh_user_transactions->insert($data); } catch(Zend_Db_Table_Exception $e){ $e; } // the parent returns so iu thoght id catch it and return that return $r; } protected function _getModel() { try {$this->_model = Zend_Registry::get('irhModel');} catch (Exception $exception) {$this->_model = null;} if (null === $this->_model) { // autoload only handles "library" components. Since this is an // application model, we need to require it from its application // path location. require_once APPLICATION_PATH . '/models/DbCluster.php'; $c = __CLASS__; $this->_model = new $c; Zend_Registry::set('irhModel',$this->_model); } return $this->_model; } } thanks for any help im just starting at this level of oop Quote Link to comment Share on other sites More sharing options...
trq Posted July 14, 2009 Share Posted July 14, 2009 You want to extend Zend_Db_Table_Abstract not Zend_Db_Table. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted July 14, 2009 Author Share Posted July 14, 2009 You want to extend Zend_Db_Table_Abstract not Zend_Db_Table. thanks v much working good now i also was missing the type public func update (array data, where) in the sig Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted July 14, 2009 Author Share Posted July 14, 2009 <?php abstract class App_Db_Table_Abstract extends Zend_Db_Table_Abstract{ function App_Db_Table_Abstract($config = null){ if(isset($this->_use_adapter)) { $dbAdapters = Zend_Registry::get('dbAdapter'); $config = ($dbAdapters[$this->_use_adapter]); } return parent::__construct($config); } public function update(array $data, $where){ $r = parent::update($data, $where); $model = $this->_getModel(); $user = Zend_Registry::get('user'); $dbAdapters = Zend_Registry::get('dbAdapter'); $db = $dbAdapters['server1']; $irh_user_transactions = $model->getTable("irh_user_transactions"); $profiler = $db->getProfiler(); $query = $profiler->getLastQueryProfile(); $params = ""; foreach($query->getQueryParams() as $p){ $params .= "'{$p}',"; } $data = array( 'user_id' => $user->user_id, 'transaction' => "QUERY: {$query->getQuery()} || PARAMS: {$params} || TIME: {$query->getElapsedSecs()}" ); try{ $irh_user_transactions->insert($data); } catch(Zend_Db_Table_Exception $e){ die($e); } return $r; } protected function _getModel() { try {$this->_model = Zend_Registry::get('irhModel');} catch (Exception $exception) {$this->_model = null;} if (null === $this->_model) { // autoload only handles "library" components. Since this is an // application model, we need to require it from its application // path location. require_once APPLICATION_PATH . '/models/DbCluster.php'; $this->_model = new Model_DbCluster(); Zend_Registry::set('irhModel',$this->_model); } return $this->_model; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.