コード例 #1
0
ファイル: sqlhelper.php プロジェクト: mrdeadmouse/u136006
 /**
  * Builds the strings for the SQL UPDATE command for the given table.
  *
  * @param string $tableName A table name.
  * @param array $fields Array("column" => $value)[].
  *
  * @return array (update, binds)
  */
 public function prepareUpdate($tableName, array $fields)
 {
     $update = array();
     $tableFields = $this->connection->getTableFields($tableName);
     foreach ($tableFields as $columnName => $tableField) {
         if (isset($fields[$columnName]) || array_key_exists($columnName, $fields)) {
             $update[] = $this->quote($columnName) . ' = ' . $this->convertToDb($fields[$columnName], $tableField);
         }
     }
     $binds = $this->prepareBinds($tableFields, $fields);
     return array(implode(", ", $update), $binds);
 }