added Doctrine_Connection::delete() method (needed as a convenience method as well as for the upcoming CTI support)
This commit is contained in:
parent
199dbbc23f
commit
8f11427595
@ -501,6 +501,30 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
return $affectedRows;
|
return $affectedRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deletes table row(s) matching the specified identifier
|
||||||
|
*
|
||||||
|
* @throws Doctrine_Connection_Exception if something went wrong at the database level
|
||||||
|
* @param string $table The table to delete data from
|
||||||
|
* @param array $identifier An associateve array containing identifier column-value pairs.
|
||||||
|
* @return integer The number of affected rows
|
||||||
|
*/
|
||||||
|
public function delete($table, array $identifier)
|
||||||
|
{
|
||||||
|
$tmp = array();
|
||||||
|
|
||||||
|
foreach (array_keys($identifier) as $id) {
|
||||||
|
$tmp[] = $id . ' = ? ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = 'DELETE FROM '
|
||||||
|
. $this->conn->quoteIdentifier($table)
|
||||||
|
. ' WHERE ' . implode(' AND ', $tmp);
|
||||||
|
|
||||||
|
|
||||||
|
return $this->conn->exec($query, array_values($identifier));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates table row(s) with specified data
|
* Updates table row(s) with specified data
|
||||||
*
|
*
|
||||||
@ -541,7 +565,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
*
|
*
|
||||||
* @param string $table The table to insert data into.
|
* @param string $table The table to insert data into.
|
||||||
* @param array $values An associateve array containing column-value pairs.
|
* @param array $values An associateve array containing column-value pairs.
|
||||||
* @return boolean
|
* @return mixed boolean false if empty value array was given,
|
||||||
|
* otherwise returns the number of affected rows
|
||||||
*/
|
*/
|
||||||
public function insert($table, array $values) {
|
public function insert($table, array $values) {
|
||||||
if (empty($values)) {
|
if (empty($values)) {
|
||||||
@ -570,9 +595,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
$query .= implode(', ', $a) . ')';
|
$query .= implode(', ', $a) . ')';
|
||||||
// prepare and execute the statement
|
// prepare and execute the statement
|
||||||
|
|
||||||
$this->exec($query, array_values($values));
|
return $this->exec($query, array_values($values));
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user