/** * Provide additional statistic update on the master module */ public function _onDelete(&$row, $old_row) { $engine =& $this->data->getProperty('engine'); if (!$engine->startTransaction()) { // This error must be caught here to avoid the rollback return false; } // Process the row $done = parent::_onDelete($row, $old_row) && $this->_updateMaster($row, -1); $done = $engine->endTransaction($done) && $done; return $done; }
/** * Process a delete action * * Overrides the default delete action erasing both master and child rows. */ public function _onDelete(&$row, $old_row) { $child =& $this->_getChildModule(); if (is_null($child)) { // No child module: chain-up the parent method return parent::_onDelete($row, $old_row); } elseif (!$child) { // An error occurred somewhere: do nothing return false; } $primary_key = $this->data->getProperty('primary_key'); if (!array_key_exists($primary_key, $row) || is_null($id = $row[$primary_key])) { TIP::warning("no primary key defined (field {$primary_key})"); return false; } $engine =& $this->data->getProperty('engine'); if (!$engine->startTransaction()) { // This error must be caught here to avoid the rollback return false; } $done = parent::_onDelete($row, $old_row) && $child->getProperty('data')->deleteRow($id); $done = $engine->endTransaction($done) && $done; return $done; }