Doctrine\DBAL\Connection::delete PHP Method

delete() public method

Table expression and columns are not escaped and are not safe for user-input.
public delete ( string $tableExpression, array $identifier, array $types = [] ) : integer
$tableExpression string The expression of the table on which to delete.
$identifier array The deletion criteria. An associative array containing column-value pairs.
$types array The types of identifiers.
return integer The number of affected rows.
    public function delete($tableExpression, array $identifier, array $types = array())
    {
        if (empty($identifier)) {
            throw InvalidArgumentException::fromEmptyCriteria();
        }
        $criteria = array();
        foreach (array_keys($identifier) as $columnName) {
            $criteria[] = $columnName . ' = ?';
        }
        return $this->executeUpdate('DELETE FROM ' . $tableExpression . ' WHERE ' . implode(' AND ', $criteria), array_values($identifier), is_string(key($types)) ? $this->extractTypeValues($identifier, $types) : $types);
    }

Usage Example

コード例 #1
0
ファイル: System.php プロジェクト: hikmahtiar6/drafterbit
 /**
  * Update system data on databse
  *
  * @param array $system
  */
 public function update($system)
 {
     foreach ($system as $key => $value) {
         $this->databaseConnection->delete($this->systemTable, ['`key`' => $key]);
         $this->insert($key, $value);
     }
 }
All Usage Examples Of Doctrine\DBAL\Connection::delete