Use the from()
method to specify FROM expression.
$delete->from('foo');
(All WHERE
methods support implicit and sprintf() inline value binding.)
The Delete WHERE
methods work just like their equivalent Select methods:
where()
and andWhere()
AND a WHERE conditionorWhere()
ORs a WHERE conditioncatWhere()
concatenates onto the end of the most-recent WHERE conditionwhereSprintf()
and andWhereSprintf()
AND a WHERE condition with sprintf()orWhereSprintf()
ORs a WHERE condition with sprintf()catWhereSprintf()
concatenates onto the end of the most-recent WHERE condition with sprintf()Some databases (notably MySQL) recognize an ORDER BY
clause. You can add one
to the Delete with the orderBy()
method; pass each expression as a variadic
argument.
// DELETE ... ORDER BY foo, bar, baz
$delete
->orderBy('foo')
->orderBy('bar', 'baz');
Some databases (notably MySQL and SQLite) recognize a LIMIT
clause; others
(notably SQLite) recognize an additional OFFSET
. You can add these to the
Delete with the limit()
and offset()
methods:
// LIMIT 10 OFFSET 40
$delete
->limit(10)
->offset(40);
Some databases (notably PostgreSQL) recognize a RETURNING
clause. You can add
one to the Delete using the returning()
method, specifying columns as
variadic arguments.
// DELETE ... RETURNING foo, bar, baz
$delete
->returning('foo')
->returning('bar', 'baz');
You can set flags recognized by your database server using the setFlag()
method. For example, you can set a MySQL LOW_PRIORITY
flag like so:
// DELETE LOW_PRIORITY foo WHERE baz = :_1_1_
$delete
->from('foo')
->where('baz = ', $baz_value)
->setFlag('LOW_PRIORITY');