1.4.6. DELETE Building The Query FROM

Use the from() method to specify FROM expression.

$delete->from('foo'); WHERE

(All WHERE methods support inline value binding via optional trailing arguments.)

The Delete WHERE methods work just like their equivalent Select methods:

  • where() and andWhere() AND a WHERE condition
  • orWhere() ORs a WHERE condition
  • catWhere() concatenates onto the end of the most-recent WHERE condition. ORDER BY

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
    ->orderBy('bar', 'baz'); LIMIT and OFFSET

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:

    ->offset(40); RETURNING

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
    ->returning('bar', 'baz'); Flags

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__
    ->where('baz = ', $baz_value)
    ->setFlag('LOW_PRIORITY'); Performing The Query

Once you have built the query, call the perform() method to execute it and get back a PDOStatement.

$result = $delete->perform(); // : PDOStatement