/** * @param array|\DibiRow $article * @return bool */ public function save(&$article) { if (!isset($article['id'])) { $this->database->insert(self::TABLE, $article)->execute(); $article['id'] = $this->database->getInsertId(); } else { $this->database->update(self::TABLE, $article)->where(self::TABLE, '.id = %i', $article['id'])->execute(); } return $this->database->getAffectedRows() == 1; }
public function update($user) { try { $this->database->update(self::TABLE_NAME, $user)->where(self::COLUMN_ID . " = ?", $user->id)->execute(); } catch (Nette\Database\DriverException $e) { throw new \Nette\Database\DriverException(); } }
public function createUpdateOne($table, $primaryColumn, $primaryValue, array $values) { $type = is_object($primaryValue) ? get_class($primaryValue) : gettype($primaryValue); $query = new Query($this->connection->update($table, $values)); $query->fluent->where("%n = " . $query->getModificators()[$type], $primaryColumn, $primaryValue); $query->resultCallback = function (Query $query) { $query->fluent->execute(); return $this->connection->getAffectedRows() === 0 ? false : true; }; return $query; }
/** * @param object $instance * @param ClassMetadata $entityAttributes * @param string $originValueHash * @return bool */ private function updateItem($instance, ClassMetadata $entityAttributes, $originValueHash) { if ($originValueHash == $this->getInstanceValuesHash($instance, $entityAttributes)) { return FALSE; } if ($entityAttributes->hasBeforeUpdateEvent()) { $instance->beforeUpdateEvent($this); } $values = $this->getInstanceValueMap($instance, $entityAttributes); return $this->dibiConnection->update($entityAttributes->getTable(), $values)->where($this->buildPrimaryKey($instance, $entityAttributes))->execute(\dibi::AFFECTED_ROWS) == 1; }
public function update($id, array $data) { return $this->connection->update($this->table, $data)->where('id=%i', $id)->execute(); }