public function buildUpdate(DomainObject $object) { $values = $object->fetchDirty(); if (!count($values)) { return false; } $query = sprintf('UPDATE `%s` AS %s', $this->table, $this->prefix) . PHP_EOL; $query .= 'SET '; foreach ($values as $key => $value) { $query .= PHP_EOL . sprintf('%s = %s, ', $this->quoteField($key), $this->quote($value)); } // Remove last ", " $query = substr($query, 0, -2); $query .= PHP_EOL . sprintf('WHERE %s = %s LIMIT 1', $this->quoteField($this->primary_key), $this->quote($object->getID())); return $query; }
public function uptodate(DomainObject $object) { return !$object->getID() ? $this->insert($object) : $this->update($object); }