You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adam Patterson edited this page Dec 18, 2012
·
1 revision
####A Simple DELETE
Deleting rows from a table is very much like a SELECT query:
// Select the table
$table = db('mytable');
// Query the database
$table->delete()
->where('user','=','Evan')
->execute();
The above is the same as the following SQL:
DELETE FROM `mytable` WHERE `user`='Evan'
Because the above example is really simple it can be done shorthand:
// Select the table
$table = db('mytable');
// Query the database
$table->delete('user','=','Evan');
####A More Complex Example
We can add multiple WHERE conditions to our query easily:
// Select the table
$table = db('mytable');
// Query the database
$table->delete()
->where('user','=','Evan')
->clause('OR')
->where('id','>=',25)
->execute();
DELETE FROM `mytable` WHERE `user`='Evan' OR `id`>='25'