* @package Mammut\DB\Sql */ class Update extends Query { use Selective; use Targetable; use Limitable; use Orderable; // const VALUES_MERGE = 'merge'; const VALUES_SET = 'set'; /** * Constructor * * @param null|string|Table $table */ public function __construct($table = null) { if($table) $this->from($table); $this->where = new Where(); } /** * Set key/value pairs to update * * @param array $values * Associative array of key values * @param string $flag * One of the VALUES_* constants * @throws \InvalidArgumentException * @return $this */ public function set(array $values) { if(empty($values)) throw new \InvalidArgumentException('set() expects an array of values'); $this->setup[self::VALUES_SET] = $values; return $this; } public function getSql(iDialect $dialect = null) { $dialect = $dialect ? $dialect : new \Mammut\DB\Sql\Dialect\Sql92(); $sql = $dialect->getUpdateSQL($this->setup); return $sql; } }