function dbQuery($sql, $parameters = array()) { global $fullSql, $debug, $sql_debug, $console_color, $database_link; $fullSql = dbMakeQuery($sql, $parameters); if ($debug) { if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { if (preg_match('/(INSERT INTO `alert_log`).*(details)/i', $fullSql)) { echo "\nINSERT INTO `alert_log` entry masked due to binary data\n"; } else { print $console_color->convert("\nSQL[%y" . $fullSql . '%n] '); } } else { $sql_debug[] = $fullSql; } } /* if($this->logFile) $time_start = microtime(true); */ $result = mysqli_query($database_link, $fullSql); // sets $this->result /* if($this->logFile) { $time_end = microtime(true); fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n"); } */ if ($result === false && error_reporting() & 1) { // aye. this gets triggers on duplicate Contact insert // trigger_error('QDB - Error in query: ' . $fullSql . ' : ' . mysql_error(), E_USER_WARNING); } return $result; }
function dbQuery($sql, $parameters = array()) { global $fullSql, $debug, $sql_debug, $console_color; $fullSql = dbMakeQuery($sql, $parameters); if ($debug) { if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { print $console_color->convert("\nSQL[%y" . $fullSql . "%n] "); } else { $sql_debug[] = $fullSql; } } /* if($this->logFile) $time_start = microtime(true); */ $result = mysql_query($fullSql); // sets $this->result /* if($this->logFile) { $time_end = microtime(true); fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n"); } */ if ($result === false && error_reporting() & 1) { // aye. this gets triggers on duplicate Contact insert //trigger_error('QDB - Error in query: ' . $fullSql . ' : ' . mysql_error(), E_USER_WARNING); } return $result; }
function dbQuery($sql, $parameters = array()) { global $fullSql, $debug; $fullSql = dbMakeQuery($sql, $parameters); if ($debug) { if ($GLOBALS['cli']) { print_message("\nSQL[%y" . $fullSql . "%n] ", 'color'); } else { print_sql($fullSql); } } if ($GLOBALS['config']['profile_sql']) { $time_start = microtime(true); } $result = mysql_query($fullSql); // sets $this->result if ($GLOBALS['config']['profile_sql']) { $time_end = microtime(true); #fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n"); $GLOBALS['sql_profile'][] = array('sql' => $fullSql, 'time' => number_format($time_end - $time_start, 8)); } if ($result === false && error_reporting() & 1) { // aye. this gets triggers on duplicate Contact insert //trigger_error('QDB - Error in query: ' . $fullSql . ' : ' . mysql_error(), E_USER_WARNING); } return $result; }
function dbQuery($sql, $parameters = array()) { global $fullSql, $debug; $fullSql = dbMakeQuery($sql, $parameters); if ($debug) { # print Console_Color::convert("\nSQL[%y".$fullSql."%n] "); echo "\nSQL[" . $fullSql . "] "; } /* if($this->logFile) $time_start = microtime(true); */ $result = mysql_query($fullSql); // sets $this->result /* if($this->logFile) { $time_end = microtime(true); fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n"); } */ if ($result === false && error_reporting() & 1) { // aye. this gets triggers on duplicate Contact insert //trigger_error('QDB - Error in query: ' . $fullSql . ' : ' . mysql_error(), E_USER_WARNING); } return $result; }
function dbQuery($sql, $parameters = array()) { global $fullSql; $fullSql = dbMakeQuery($sql, $parameters); if (OBS_DEBUG) { // Pre query debug output if (is_cli()) { print_message(PHP_EOL . 'SQL[%y' . $fullSql . '%n]', 'console', FALSE); } else { print_sql($fullSql); } } if (OBS_DEBUG || $GLOBALS['config']['profile_sql']) { $time_start = microtime(true); } $result = mysql_query($fullSql); // sets $this->result if (OBS_DEBUG || $GLOBALS['config']['profile_sql']) { $runtime = number_format(microtime(true) - $time_start, 8); $debug_msg .= 'RUNTIME[' . ($runtime > 0.05 ? '%r' : '%g') . $runtime . 's%n]'; if ($GLOBALS['config']['profile_sql']) { #fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n"); $GLOBALS['sql_profile'][] = array('sql' => $fullSql, 'time' => $runtime); } } if (OBS_DEBUG) { if ($result === FALSE && error_reporting() & 1) { // aye. this gets triggers on duplicate Contact insert //trigger_error('QDB - Error in query: ' . $fullSql . ' : ' . mysql_error(), E_USER_WARNING); $error_msg = 'Error in query: (' . mysql_errno() . ') ' . mysql_error(); $debug_msg .= PHP_EOL . 'ERROR[%r' . $error_msg . '%n]'; } if (is_cli()) { if (OBS_DEBUG > 1) { $rows = mysql_affected_rows(); $debug_msg = 'ROWS[' . ($rows < 1 ? '%r' : '%g') . $rows . '%n]' . PHP_EOL . $debug_msg; } // After query debug output for cli print_message($debug_msg, 'console', FALSE); } else { print_error($error_msg); } } return $result; }
function dbQuery($sql, $parameters = array()) { global $fullSql; $fullSql = dbMakeQuery($sql, $parameters); if (OBS_DEBUG > 0) { // Pre query debug output if (is_cli()) { $debug_sql = explode(PHP_EOL, $fullSql); print_message(PHP_EOL . 'SQL[%y' . implode('%n' . PHP_EOL . '%y', $debug_sql) . '%n]', 'console', FALSE); } else { print_sql($fullSql); } } if (OBS_DEBUG > 0 || $GLOBALS['config']['profile_sql']) { $time_start = microtime(true); } $result = dbCallQuery($fullSql); // sets $this->result if (OBS_DEBUG > 0 || $GLOBALS['config']['profile_sql']) { $runtime = number_format(microtime(true) - $time_start, 8); $debug_msg .= 'SQL RUNTIME[' . ($runtime > 0.05 ? '%r' : '%g') . $runtime . 's%n]'; if ($GLOBALS['config']['profile_sql']) { #fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n"); $GLOBALS['sql_profile'][] = array('sql' => $fullSql, 'time' => $runtime); } } if (OBS_DEBUG > 0) { if ($result === FALSE && error_reporting() & 1) { $error_msg = 'Error in query: (' . dbError() . ') ' . dbErrorNo(); $debug_msg .= PHP_EOL . 'ERROR[%r' . $error_msg . '%n]'; } if (is_cli()) { if (OBS_DEBUG > 1) { $rows = dbAffectedRows(); $debug_msg = 'ROWS[' . ($rows < 1 ? '%r' : '%g') . $rows . '%n]' . PHP_EOL . $debug_msg; } // After query debug output for cli print_message($debug_msg, 'console', FALSE); } else { print_error($error_msg); } } if ($result === FALSE && isset($GLOBALS['config']['db']['debug']) && $GLOBALS['config']['db']['debug']) { logfile('db.log', 'Failed dbQuery (#' . dbErrorNo() . ' - ' . dbError() . '), Query: ' . $fullSql); } return $result; }