$stmt = $connection->update();
// UPDATE ...SQLServer only.
$stmt->top(10);
// UPDATE TOP (10) ...$stmt->top(10)->percent();
// UPDATE TOP (10) PERCENT ...$stmt->table('t1');
// UPDATE t1$stmt->table('t1', 't2');
// UPDATE t1, t2$stmt->table(['a' => 't1', 'b' => 't2']);
// UPDATE t1 a, t2 bSee Subquery.
$stmt->table(
$connection->select()
->columns('c1')
->from('t1')
);
// UPDATE (SELECT c1 FROM t1)See Table.
use MichaelRushton\Database\SQL\Components\Table;
$stmt->table(new Table('t1'));
// UPDATE t1$stmt->set('c1', $param);
// UPDATE ... SET c1 = ?
$stmt->set([
'c1' => $param1,
'c2' => $param2,
]);
// UPDATE ... SET c1 = ?, c2 = ?
See join.
$stmt->join('t2');
// UPDATE ... JOIN t2See where.
$stmt->where('c1', $param);
// UPDATE ... WHERE c1 = ?
PostgreSQL and SQLServer only.
$stmt->whereCurrentOf('cursor');
// UPDATE ... WHERE CURRENT OF cursorMariaDB, MySQL and SQLite only.
See order by.
$stmt->orderBy('c1');
// UPDATE ... ORDER BY c1MariaDB, MySQL, and SQLite only.
See limit.
$stmt->limit(10);
// UPDATE ... LIMIT 10See with.
use MichaelRushton\Database\SQL\Components\CTE;
$stmt->cte(
'cte1',
function ($select)
{
$select->from('t1');
},
function (CTE $cte)
{
}
);
// WITH cte1 AS (SELECT * t1) UPDATE ...MariaDB and MySQL only.
$stmt->lowPriority();
// UPDATE LOW_PRIORITY ...MariaDB and MySQL only.
$stmt->ignore();
// UPDATE IGNORE ...SQLite only.
$stmt->orFail();
// UPDATE OR FAIL ...SQLite only.
$stmt->orIgnore();
// UPDATE OR IGNORE ...SQLite only.
$stmt->orReplace();
// UPDATE OR REPLACE ...SQLite only.
$stmt->orRollBack();
// UPDATE OR ROLLBACK ...PostgreSQL, SQLite, and SQLServer only.
See from.
$stmt->from('t1');
// UPDATE ... FROM t1See returning.
MariaDB, PostgreSQL and SQLite only.
$stmt->returning();
// UPDATE ... RETURNING *SQLServer only.
$stmt->output('INSERTED.c1', 'DELETED.c1');
// UPDATE ... OUTPUT INSERTED.c1, DELETED.c1 ...$stmt->output(['a' => 'INSERTED.c1', 'b' => 'DELETED.c1']);
// UPDATE ... OUTPUT INSERTED.c1 a, DELETED.c1 b ...