1
0
mirror of synced 2024-12-14 23:26:04 +03:00
doctrine2/manual/docs/DQL (Doctrine Query Language) - DELETE queries.php

36 lines
968 B
PHP
Raw Normal View History

2007-04-14 01:49:11 +04:00
<code>
DELETE FROM <component_name>
[WHERE <where_condition>]
2007-04-14 01:49:11 +04:00
[ORDER BY ...]
[LIMIT <record_count>]
2007-04-14 01:49:11 +04:00
</code>
* The DELETE statement deletes records from //component_name// and returns the number of records deleted.
* The optional WHERE clause specifies the conditions that identify which records to delete.
Without WHERE clause, all records are deleted.
* If the ORDER BY clause is specified, the records are deleted in the order that is specified.
* The LIMIT clause places a limit on the number of rows that can be deleted.
2007-04-14 01:49:11 +04:00
The statement will stop as soon as it has deleted //record_count// records.
<code type="php">
$q = 'DELETE FROM Account WHERE id > ?';
$rows = $this->conn->query($q, array(3));
// the same query using the query interface
$q = new Doctrine_Query();
$rows = $q->delete('Account')
->from('Account a')
->where('a.id > ?', 3)
->execute();
2007-04-14 01:49:11 +04:00
print $rows; // the number of affected rows
</code>