Esempio n. 1
0
 /**
  * Updates the table with the specified $aValues where $idColumn equals
  * $id. Returns number of rows updated on success or PEAR::Error on
  * failure.
  *
  * @param string $table
  * @param string $idColumn
  * @param string $id
  * @param array $aValues A map from column name => new value
  * @return int Number of rows updated on success or PEAR::Error on failure.
  */
 function updateWhereOne($table, $idColumn, $id, $aValues)
 {
     $aSet = array();
     foreach ($aValues as $column => $value) {
         $aSet[] = "{$column} = " . DBC::makeLiteral($value);
     }
     $sSet = implode(",", $aSet);
     $table = OA_DB_Sql::modifyTableName($table);
     $sql = "UPDATE {$table} SET {$sSet} WHERE {$idColumn} = {$id}";
     $dbh =& OA_DB::singleton();
     return $dbh->exec($sql);
 }