Query_Builder_Delete class
(extends Query_Builder_Where)
The Query_Builder_Delete class handles all the delete operations for the query building process. It extends the
Query_Builder_Where class, so all the methods are inherited.
Methods
table($table)
The table method sets/changes the table to delete from.
Static |
No |
Parameters |
Param |
Type |
Default |
Description |
$table |
string |
required |
the table name |
|
Returns |
Returns the current instance. |
Example |
// prepare an update statement
$query = DB::delete('users');
// Set the table to delete from
$query->table('admins');
// DELETE `admins` ...
|
compile(\Database_Connection$db)
The compile method returns the delete SQL query as a string.
Static |
No |
Parameters |
Param |
Type |
Default |
Description |
$db |
object |
required |
A database connection |
|
Returns |
Returns the SQL query as a string. |
Example |
// prepare an update statement
$query = DB::delete('users');
// Set a where statement
$query->where('looks', 'like', '%spammer%');
// Get the database connection
$connection = Database_Connection::instance();
// Get the sql query
$sql = $query->compile($connection);
// DELETE FROM `users` WHERE `looks` LIKE "%spammer%"
|
reset()
The reset method resets all values of the current instance.
Static |
No |
Parameters |
None
|
Returns |
Returns the current instance. |
Example |
// prepare an update statement
$query = DB:delete('users');
// Set a where statement
$query->where('it_look', 'ok to me');
// Reset it
$query->reset();
// Just an other where statement
$query->where('looks', 'like', '%bad mister%');
// Get the database connection
$connection = Database_Connection::instance();
// Get the sql query
$sql = $query->compile($connection);
// DELETE FROM `users` WHERE `looks` LIKE "%bad mister%"
|