|
Previous Page |
Solar_Sql_Adapter |
Next Page |
delete()
public
int
delete (
string $table,
string|array $where
)
Deletes rows from the table based on a WHERE clause.
Parameters
- (string)
$table: The table to delete from. - (string|array)
$where: The SQL WHERE clause to limit which rows are deleted.
Returns
- (int) The number of rows affected.
Description
Deletes rows from the table based on a WHERE clause.
For example ...
<?php
$sql = Solar::factory('Solar_Sql');
$table = 'events';
$where = $sql->quoteInto('status = ?', 'cancelled');
$rows_affected = $sql->delete($table, $where);
// calls 'DELETE FROM events WHERE status = "cancelled"'
?>
For the $where parameter, you can also pass multiple WHERE conditions as an array to be "AND"ed together.
<?php
$sql = Solar::factory('Solar_Sql');
$table = 'events';
$where = array(
"date >= ?" => '2006-01-01',
"date <= ?" => '2006-01-31',
"status = ?" => 'cancelled',
);
$rows_affected = $sql->delete($table, $where);
// calls:
// DELETE FROM events WHERE date >= "2006-01-01"
// AND date <= "2006-01-31" AND status = "cancelled"
?> Local
- Overview
- Constants
- Properties
- Methods
- __construct()
- __destruct()
- _addProfile()
- _bind()
- _buildDsn()
- _checkIdentifier()
- _createSequence()
- _dropIndex()
- _dropSequence()
- _exception()
- _fetchTableCols()
- _fetchTableList()
- _getCacheKey()
- _getTypeSizeScope()
- _modAutoincPrimary()
- _modIndexName()
- _modSelect()
- _modSequenceName()
- _nextSequence()
- _postConnect()
- _prepare()
- _quoteName()
- _quoteNamesIn()
- _select()
- _setDsn()
- _setup()
- _sqlColdef()
- _sqlCreateTable()
- _sqlSelect()
- addColumn()
- apiVersion()
- begin()
- commit()
- connect()
- createIndex()
- createSequence()
- createTable()
- delete()
- disconnect()
- dropColumn()
- dropIndex()
- dropSequence()
- dropTable()
- dump()
- fetchAll()
- fetchAssoc()
- fetchCol()
- fetchOne()
- fetchPairs()
- fetchPdo()
- fetchSql()
- fetchTableCols()
- fetchTableList()
- fetchValue()
- getCache()
- getCacheKeyPrefix()
- getPdo()
- getProfile()
- insert()
- lastInsertId()
- locale()
- nextSequence()
- query()
- quote()
- quoteInto()
- quoteMulti()
- quoteName()
- quoteNamesIn()
- rollback()
- setCache()
- setCacheKeyPrefix()
- setProfiling()
- update()