mirror of
https://github.com/friendica/friendica
synced 2025-05-06 18:24:10 +02:00
New function "dba::update" and changed unique index for the conversations
This commit is contained in:
parent
3b5e1bbfc3
commit
782783aa52
4 changed files with 37 additions and 3 deletions
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue