public function save(Gyuser_Model_Operations $obj) { $data = array('client_id' => $obj->getClient_id(), 'date' => $obj->getDate(), 'amount' => $obj->getAmount(), 'state_order_id' => $obj->getState(), 'observations' => $obj->getObservations(), 'report' => $obj->getReport(), 'date_added' => date('Y-m-d H:i:s'), 'cave_id' => $obj->getCave_id() == 'null' ? null : $obj->getCave_id(), 'bank_account_id' => (int) $obj->getBank_account_id()); $id = (int) $obj->getId(); if (!$id) { unset($data['id']); $id = $this->getDbTable()->insert($data); return $id; } else { $id = $this->getDbTable()->update($data, array('id = ?' => $id)); return $id; } }