From 653444790b2c58488130a71c976f743693811dbb Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 19 Nov 2011 20:17:29 +0000 Subject: [PATCH] * (bug 8859) Database::update should take array of tables too Original patch by Andrew Dunbar Also apply in DatabaseOracle and DB2 code as they override update --- includes/db/Database.php | 16 ++++++++++------ includes/db/DatabaseIbm_db2.php | 6 +++++- includes/db/DatabaseOracle.php | 6 +++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index 4b54b8e4f1..8dc2a9edee 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1683,28 +1683,32 @@ abstract class DatabaseBase implements DatabaseType { /** * UPDATE wrapper. Takes a condition array and a SET array. * - * @param $table String name of the table to UPDATE. This will be passed through + * @param $table String|array name of the table to UPDATE. This will be passed through * DatabaseBase::tableName(). * - * @param $values Array: An array of values to SET. For each array element, + * @param $values Array An array of values to SET. For each array element, * the key gives the field name, and the value gives the data * to set that field to. The data will be quoted by * DatabaseBase::addQuotes(). * - * @param $conds Array: An array of conditions (WHERE). See + * @param $conds Array An array of conditions (WHERE). See * DatabaseBase::select() for the details of the format of * condition arrays. Use '*' to update all rows. * - * @param $fname String: The function name of the caller (from __METHOD__), + * @param $fname String The function name of the caller (from __METHOD__), * for logging and profiling. * - * @param $options Array: An array of UPDATE options, can be: + * @param $options Array An array of UPDATE options, can be: * - IGNORE: Ignore unique key conflicts * - LOW_PRIORITY: MySQL-specific, see MySQL manual. * @return Boolean */ function update( $table, $values, $conds, $fname = 'DatabaseBase::update', $options = array() ) { - $table = $this->tableName( $table ); + if ( is_array( $table ) ) { + $table = implode( ',', array_map( array( $this, 'tableName' ), $table ) ); + } else { + $table = $this->tableName( $table ); + } $opts = $this->makeUpdateOptions( $options ); $sql = "UPDATE $opts $table SET " . $this->makeList( $values, LIST_SET ); diff --git a/includes/db/DatabaseIbm_db2.php b/includes/db/DatabaseIbm_db2.php index 67ca80a4ae..eb91478012 100644 --- a/includes/db/DatabaseIbm_db2.php +++ b/includes/db/DatabaseIbm_db2.php @@ -984,7 +984,11 @@ class DatabaseIbm_db2 extends DatabaseBase { public function update( $table, $values, $conds, $fname = 'DatabaseIbm_db2::update', $options = array() ) { - $table = $this->tableName( $table ); + if ( is_array( $table ) ) { + $table = implode( ',', array_map( array( $this, 'tableName' ), $table ) ); + } else { + $table = $this->tableName( $table ); + } $opts = $this->makeUpdateOptions( $options ); $sql = "UPDATE $opts $table SET " . $this->makeList( $values, LIST_SET_PREPARED ); diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 664e7da609..d807201edd 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -1197,7 +1197,11 @@ class DatabaseOracle extends DatabaseBase { function update( $table, $values, $conds, $fname = 'DatabaseOracle::update', $options = array() ) { global $wgContLang; - $table = $this->tableName( $table ); + if ( is_array( $table ) ) { + $table = implode( ',', array_map( array( $this, 'tableName' ), $table ) ); + } else { + $table = $this->tableName( $table ); + } $opts = $this->makeUpdateOptions( $options ); $sql = "UPDATE $opts $table SET "; -- 2.20.1