/** * Update record * @param Record $entry */ public function update(Record $entry) { $where = array("_id" => $entry->_id); $data = $entry->getAttributes(); $this->getDbConnection()->update($entry::getTable(), $where, $data); }
/** * Save the object to the database * @param \Edge\Models\Record $entry */ public function save(Record $entry) { $db = Edge::app()->writedb; $table = $entry->getTable(); $pks = $entry->getPk(); if (count($pks) > 0) { $metadata = $db->dbMetadata($table); foreach ($pks as $attr) { if (isset($metadata[$attr]) && $metadata[$attr][1] & \MYSQLI_AUTO_INCREMENT_FLAG) { if ($entry->{$attr} == "") { $entry->{$attr} = 0; } } } } $data = array_map(function ($v) use($db) { return sprintf('"%s"', $db->dbEscapeString($v)); }, $entry->getAttributes()); $db->dbQuery($this->getInsertQuery($data, $entry)); $this->setAutoIncrement($entry); }