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. |
리턴 | 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);
}
/** * 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); } }