if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
if (! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
self::$error = L10n::t('Cannot locate DNS info for database server \'%s\'', $server);
if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
if (! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
self::$error = L10n::t('Cannot locate DNS info for database server \'%s\'', $server);
self::$db = @new PDO($connect, $user, $pass);
self::$connected = true;
} catch (PDOException $e) {
self::$db = @new PDO($connect, $user, $pass);
self::$connected = true;
} catch (PDOException $e) {
* @param array $args The parameters that are to replace the ? placeholders
* @return string The replaced SQL query
*/
* @param array $args The parameters that are to replace the ? placeholders
* @return string The replaced SQL query
*/
// The fallback routine is called as well when there are no arguments
if (!$can_be_prepared || (count($args) == 0)) {
// The fallback routine is called as well when there are no arguments
if (!$can_be_prepared || (count($args) == 0)) {
@file_put_contents($a->config["system"]["db_log"], DateTimeFormat::utcNow()."\t".$duration."\t".
basename($backtrace[1]["file"])."\t".
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
@file_put_contents($a->config["system"]["db_log"], DateTimeFormat::utcNow()."\t".$duration."\t".
basename($backtrace[1]["file"])."\t".
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
- substr(self::replace_parameters($sql, $args), 0, 2000)."\n", FILE_APPEND);
+ substr(self::replaceParameters($sql, $args), 0, 2000)."\n", FILE_APPEND);
- $array_element = each($condition);
- $array_key = $array_element['key'];
- if (!is_int($array_key)) {
- $fields = [$array_key];
+ reset($condition);
+ $first_key = key($condition);
+ if (!is_int($first_key)) {
+ $fields = [$first_key];
}
$stmt = self::select($table, $fields, $condition, ['limit' => 1]);
}
$stmt = self::select($table, $fields, $condition, ['limit' => 1]);
$sql = "DELETE FROM `" . $table . "` WHERE `" . $field . "` IN (" .
substr(str_repeat("?, ", count($field_values)), 0, -2) . ");";
$sql = "DELETE FROM `" . $table . "` WHERE `" . $field . "` IN (" .
substr(str_repeat("?, ", count($field_values)), 0, -2) . ");";
- if (is_array($condition) && (count($condition) > 0)) {
- $array_element = each($condition);
- $array_key = $array_element['key'];
- if (is_int($array_key)) {
+ if (count($condition) > 0) {
+ reset($condition);
+ $first_key = key($condition);
+ if (is_int($first_key)) {
$placeholders = substr(str_repeat("?, ", count($value)), 0, -2);
$condition_string .= "`" . $field . "` IN (" . $placeholders . ")";
} else {
$placeholders = substr(str_repeat("?, ", count($value)), 0, -2);
$condition_string .= "`" . $field . "` IN (" . $placeholders . ")";
} else {