// for backtracking the function calls to the page and line number.
function get_functions($trace){
if (count($trace) == 0)
return '';
else {
$array = array_shift($trace);
$str = 'page: '.array_pop(explode('/', $array['file'])).' function: '.$array['function'].' line: '.$array['line'].'
';
return get_functions($trace).$str;
}
}
//Query function, all MySQL query's run though this,
//$var, raw query string.
//$print, output this for viewing purposes.
function query($var, $print = false){
global $mysql_query_info, $config;
if ($config['QUERY_OUTPUT'])//if in "development" show all query's.
$print = true;
$time = microtime(true);//store current time for timing purposes.
$data = mysql_query($var);// run query
$time = round(microtime(true)-$time, 6);//get the time the query ran.
if ($time > 0.5){//if the time is longer then half a second...
trigger_error($time.' - '.$var);//notify me thoguh a php error.
}
if ($print){//if print, store information to a structured array to be outputted at the end of file execution.
$rows = mysql_affected_rows();
$str = '';
if (mysql_errno() == 0 && strpos($var, 'SELECT') === 0){// see if this a select query that has not errored and if it is run a mysql EXPLAIN to check for database optimizations.
$dat = mysql_query('EXPLAIN '.$var);
$outarr = array();
while($exp = mysql_fetch_assoc($dat)){// for each table find, format, and save the output.
$str1 = array();
$str2 = array();
foreach($exp as $key => $val){
$str1[] = $key;
$str2[] = $val;
}
if (empty($outarr))
$outarr[] = '