New function "dba::update" and changed unique index for the conversations

This commit is contained in:
Michael 2017-04-28 05:50:27 +00:00
parent 3b5e1bbfc3
commit 782783aa52
4 changed files with 37 additions and 3 deletions

View file

@ -753,6 +753,32 @@ class dba {
return self::e($sql, $param);
}
/**
* @brief Updates rows
*
* @param string $table Table name
* @param array $fields contains the fields that are updated
* @param array $condition condition array with the key values
*
* @return boolean was the update successfull?
*/
static public function update($table, $fields, $condition) {
$sql = "UPDATE `".self::$dbo->escape($table)."` SET `".
implode("` = ?, `", array_keys($fields))."` = ? WHERE `".
implode("` = ? AND `", array_keys($condition))."` = ?";
$params = array();
foreach ($fields AS $value) {
$params[] = $value;
}
foreach ($condition AS $value) {
$params[] = $value;
}
self::e($sql, $params);
}
/**
* @brief Closes the current statement
*