/** * Saves DBObject to the database. If this is a new object - INSERT SQL * instruction executes, if existed one - UPDATE. * * @return mixed Primary key value. * @throws DBCoreException If some database error occurred. */ public function save() { if ($this->isNewRecord()) { $insertionId = DBCore::insertDBObject($this); if (Tools::isInteger($insertionId) && $insertionId > 0) { $this->setId($insertionId); } else { throw new DBCoreException("Save database object error"); } return $insertionId; } else { DBCore::updateDBObject($this); return $this->id; } }
/** * Inserts DBObject to the database. * * @param bool $ignore Ignore unique indexes or not. * @param bool Debug mode flag. * * @return mixed Primary key value. * @throws DBCoreException If some database error occurred. */ public function insert($ignore = false, $debug = false) { return DBCore::insertDBObject($this, $ignore, $debug); }