nadeemshafi9 Posted July 13, 2009 Share Posted July 13, 2009 hi guys i am extending the zend_db_table class to make it work with a clustered db system. in the child class i would like to overide a method yet preserv the parents method proceedure. i owuld like to log stuff in update yet call the parents update method. is this possible ? how do you call a parents method ??? parent::blah blah i dont know any ideas ??? thanks guys Link to comment https://forums.phpfreaks.com/topic/165825-how-to-extend-a-method-in-a-extended-class/ Share on other sites More sharing options...
ignace Posted July 13, 2009 Share Posted July 13, 2009 class My_Db_Table extends Zend_Db_Table { public function overwriteMethod() { //do something parent::overwriteMethod(); } } Link to comment https://forums.phpfreaks.com/topic/165825-how-to-extend-a-method-in-a-extended-class/#findComment-874673 Share on other sites More sharing options...
nadeemshafi9 Posted July 13, 2009 Author Share Posted July 13, 2009 class My_Db_Table extends Zend_Db_Table { public function overwriteMethod() { //do something parent::overwriteMethod(); } } will i be able to include the parent methods proceedure this way or do i have to call it parent::mthod();, thnx btw Link to comment https://forums.phpfreaks.com/topic/165825-how-to-extend-a-method-in-a-extended-class/#findComment-874742 Share on other sites More sharing options...
ignace Posted July 19, 2009 Share Posted July 19, 2009 class My_Db_Table extends Zend_Db_Table { public function overwriteMethod() { //do something parent::overwriteMethod(); } } will i be able to include the parent methods proceedure this way or do i have to call it parent::mthod();, thnx btw No you won't. Zend framework doesn't entirely come without it flaws, and one of the main complaints are what you are experiencing. You still need to copy-paste a serious amount of code to add some more functionality. The reason for this is because Zend framework is still in a serious development process and they don't intend to re-factor any code anytime soon. But eventually you'll be able to extend their code base without copy-pasting. Link to comment https://forums.phpfreaks.com/topic/165825-how-to-extend-a-method-in-a-extended-class/#findComment-878237 Share on other sites More sharing options...
nadeemshafi9 Posted July 27, 2009 Author Share Posted July 27, 2009 i managed to do it public function delete($where){ $r = parent::delete($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->logException = true; if(!$this->logException) $irh_user_transactions->insert($data); } catch(Zend_Db_Table_Exception $e){ die($e); } return $r; } 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->logException = true; if(!$this->logException) $irh_user_transactions->insert($data); } catch(Zend_Db_Table_Exception $e){ die($e); } return $r; } public function insert(array $data){ $r = parent::insert($data); $model = $this->_getModel(); $user = Zend_Registry::get('user'); $dbAdapters = Zend_Registry::get('dbAdapter'); $db = $dbAdapters['server1']; $this->lastInsertId = $db->lastInsertId(); $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->logException = true; if(!$this->logException) $irh_user_transactions->insert($data); } catch(Zend_Db_Table_Exception $e){ die($e); } return $r; } Link to comment https://forums.phpfreaks.com/topic/165825-how-to-extend-a-method-in-a-extended-class/#findComment-883924 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.