public function insert($pa_options = null) { $vb_web_set_transaction = false; if (!$this->inTransaction()) { $this->setTransaction(new Transaction($this->getDb())); $vb_web_set_transaction = true; } $o_trans = $this->getTransaction(); if (!strlen($this->get('is_enabled'))) { $this->set('is_enabled', 1); } $vn_rc = parent::insert($pa_options); if ($this->numErrors()) { if ($vb_web_set_transaction) { $o_trans->rollback(); } } else { if ($vb_web_set_transaction) { $o_trans->commit(); } } return $vn_rc; }
/** * Override insert() to add child records to the same lot as parent */ public function insert($pa_options = null) { if ($vn_parent_id = $this->get('parent_id')) { $t_parent = new ca_objects(); if ($this->inTransaction()) { $t_parent->setTransaction($this->getTransaction()); } if ($t_parent->load($vn_parent_id) && ($vn_lot_id = $t_parent->get('lot_id'))) { $this->set('lot_id', $vn_lot_id); } } return parent::insert($pa_options); }