}
// }}}
+ // {{{ function _reformatQuery
+
+ function _reformatQuery($query)
+ {
+ $query = preg_split("/\n\\s*/", $query);
+ $length = 0;
+ foreach ($query as $line) {
+ if (preg_match('/^([A-Z]+( (JOIN|BY))?) /', $line, $matches)
+ && $matches[1] != 'AND' && $matches[2] != 'OR') {
+ $length = max($length, strlen($matches[1]));
+ }
+ }
+ $res = '';
+ foreach ($query as $line) {
+ $local = -2;
+ if (preg_match('/^([A-Z]+(?: (?:JOIN|BY))?) +(.*)/', $line, $matches)
+ && $matches[1] != 'AND' && $matches[2] != 'OR') {
+ $local = strlen($matches[1]);
+ $line = $matches[1] . ' ' . $matches[2];
+ }
+ $local = $length - $local;
+ $res .= str_repeat(' ', $local) . $line . "\n";
+ $length += 2 * (substr_count($line, '(') - substr_count($line, ')'));
+ }
+ return $res;
+ }
+
+ // }}}
+ // {{{ function _query
function _query($query) {
global $globals;
while ($row = @mysql_fetch_assoc($_res)) {
$explain[] = $row;
}
- $trace_data = array('query' => $query, 'explain' => $explain);
+ $trace_data = array('query' => XDB::_reformatQuery($query), 'explain' => $explain);
@mysql_free_result($_res);
}
return $res;
}
+ // }}}
// {{{ function query
function &query()
function XOrgDBResult($query)
{
- if (strpos($query, 'SQL_CALC_FOUND_ROWS') === false) {
- $this->_res = XDB::_query($query);
- } else {
- $this->_res = mysql_query($query);
- }
+ $this->_res = XDB::_query($query);
}
// }}}