Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/db/db_connection.php
Show First 20 Lines • Show All 801 Lines • ▼ Show 20 Line(s) | |||||
$insert_result = true; | $insert_result = true; | ||||
if ($insert_now) { | if ($insert_now) { | ||||
$insert_count = count($value_sqls); | $insert_count = count($value_sqls); | ||||
if (($insert_count > 1) && ($value_sqls[$insert_count - 1] == $value_sqls[$insert_count - 2])) { | if (($insert_count > 1) && ($value_sqls[$insert_count - 1] == $value_sqls[$insert_count - 2])) { | ||||
// last two records are the same | // last two records are the same | ||||
array_pop($value_sqls); | array_pop($value_sqls); | ||||
} | } | ||||
$sql = strtoupper($type) . ' INTO `' . $table . '` (' . $fields_sql . ') VALUES (' . implode('),(', $value_sqls) . ')'; | $sql = strtoupper($type) . ' INTO ' . $table . ' (' . $fields_sql . ') VALUES (' . implode('),(', $value_sqls) . ')'; | ||||
$value_sqls = Array (); // reset before query to prevent repeated call from error handler to insert 2 records instead of 1 | |||||
// Reset before query to prevent repeated call from error handler to insert 2 records instead of 1. | |||||
$value_sqls = array(); | |||||
$insert_result = $this->ChangeQuery($sql); | $insert_result = $this->ChangeQuery($sql); | ||||
} | } | ||||
return $insert_result; | return $insert_result; | ||||
} | } | ||||
/** | /** | ||||
Show All 12 Lines | |||||
$fields_sql = ''; | $fields_sql = ''; | ||||
foreach ($fields_hash as $field_name => $field_value) { | foreach ($fields_hash as $field_name => $field_value) { | ||||
$fields_sql .= '`'.$field_name.'` = ' . $this->qstr($field_value) . ','; | $fields_sql .= '`'.$field_name.'` = ' . $this->qstr($field_value) . ','; | ||||
} | } | ||||
// don't use preg here, as it may fail when string is too long | // don't use preg here, as it may fail when string is too long | ||||
$fields_sql = rtrim($fields_sql, ','); | $fields_sql = rtrim($fields_sql, ','); | ||||
$sql = 'UPDATE `'.$table.'` SET '.$fields_sql.' WHERE '.$key_clause; | $sql = 'UPDATE ' . $table . ' SET ' . $fields_sql . ' WHERE ' . $key_clause; | ||||
return $this->ChangeQuery($sql); | return $this->ChangeQuery($sql); | ||||
} | } | ||||
/** | /** | ||||
* Allows to detect table's presence in database. | * Allows to detect table's presence in database. | ||||
* | * | ||||
* @param string $table_name | * @param string $table_name | ||||
▲ Show 20 Lines • Show All 601 Lines • Show Last 20 Lines |