mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-03-06 16:16:48 +01:00
Fix handling of table prefix and quoting in insert_or_update()
In all places we use this function the $table argument has already been passed through table_name() method, i.e. it contains the prefix and is quoted. So, we should not do this again.
This commit is contained in:
@@ -224,7 +224,7 @@ class rcube_db_mysql extends rcube_db
|
||||
* INSERT ... ON DUPLICATE KEY UPDATE (or equivalent).
|
||||
* When not supported by the engine we do UPDATE and INSERT.
|
||||
*
|
||||
* @param string $table Table name
|
||||
* @param string $table Table name (should be already passed via table_name() with quoting)
|
||||
* @param array $keys Hash array (column => value) of the unique constraint
|
||||
* @param array $columns List of columns to update
|
||||
* @param array $values List of values to update (number of elements
|
||||
@@ -235,7 +235,6 @@ class rcube_db_mysql extends rcube_db
|
||||
*/
|
||||
public function insert_or_update($table, $keys, $columns, $values)
|
||||
{
|
||||
$table = $this->table_name($table, true);
|
||||
$columns = array_map(function($i) { return "`$i`"; }, $columns);
|
||||
$cols = implode(', ', array_map(function($i) { return "`$i`"; }, array_keys($keys)));
|
||||
$cols .= ', ' . implode(', ', $columns);
|
||||
|
||||
@@ -195,7 +195,7 @@ class rcube_db_pgsql extends rcube_db
|
||||
* INSERT ... ON CONFLICT DO UPDATE.
|
||||
* When not supported by the engine we do UPDATE and INSERT.
|
||||
*
|
||||
* @param string $table Table name
|
||||
* @param string $table Table name (should be already passed via table_name() with quoting)
|
||||
* @param array $keys Hash array (column => value) of the unique constraint
|
||||
* @param array $columns List of columns to update
|
||||
* @param array $values List of values to update (number of elements
|
||||
@@ -211,7 +211,6 @@ class rcube_db_pgsql extends rcube_db
|
||||
return parent::insert_or_update($table, $keys, $columns, $values);
|
||||
}
|
||||
|
||||
$table = $this->table_name($table, true);
|
||||
$columns = array_map([$this, 'quote_identifier'], $columns);
|
||||
$target = implode(', ', array_map([$this, 'quote_identifier'], array_keys($keys)));
|
||||
$cols = $target . ', ' . implode(', ', $columns);
|
||||
|
||||
@@ -576,7 +576,7 @@ class rcube_db
|
||||
* INSERT ... ON DUPLICATE KEY UPDATE (or equivalent).
|
||||
* When not supported by the engine we do UPDATE and INSERT.
|
||||
*
|
||||
* @param string $table Table name
|
||||
* @param string $table Table name (should be already passed via table_name() with quoting)
|
||||
* @param array $keys Hash array (column => value) of the unique constraint
|
||||
* @param array $columns List of columns to update
|
||||
* @param array $values List of values to update (number of elements
|
||||
@@ -587,7 +587,6 @@ class rcube_db
|
||||
*/
|
||||
public function insert_or_update($table, $keys, $columns, $values)
|
||||
{
|
||||
$table = $this->table_name($table, true);
|
||||
$columns = array_map(function($i) { return "`$i`"; }, $columns);
|
||||
$sets = array_map(function($i) { return "$i = ?"; }, $columns);
|
||||
$where = $keys;
|
||||
|
||||
Reference in New Issue
Block a user