$query = $connection
->delete()
->from('accounts')
->where('name', '=', 'Account 1');
$statement = $connection->query($query);
You can get the number of affected rows:
$rowCount = $statement->getRowCount();
This clause is shared by multiple queries (SELECT, UPDATE, DELETE).
The following section of the documentation explains how to use the JOIN clause.
This clause is shared by multiple queries (SELECT, UPDATE, DELETE).
The following section of the documentation explains how to use the WHERE clause.
Usage:
use Foundry\Parameter;
$query = $connection
->delete()
->from('accounts')
->where('name', '=', new Parameter);
$statement = $connection->query($query, ['Account 1']);
Usage:
use Foundry\Parameter;
$query = $connection
->delete()
->from('accounts')
->where('name', '=', new Parameter('name'));
$statement = $connection->query($query, [':name' => 'Account 1']);
All clauses are additive. For example, adding a join to the query will not remove previously declared joins.
To reset a part of the query, you can use the reset
method:
public function reset($part = null);
Usage:
use Foundry\Builder\Statement\Delete;
$query->reset(Delete::PART_JOIN);
To completely reset the query:
$query->reset();
The reset
method is also provided by the other statements (select, insert, update).