added sql-debugging to lib2 search.php

This commit is contained in:
following
2013-07-15 00:39:09 +02:00
parent f6ba21a94b
commit 0e84773211
17 changed files with 128 additions and 121 deletions
+2
View File
@@ -283,6 +283,8 @@ class OcSmarty extends Smarty
if (($opt['debug'] & DEBUG_SQLDEBUGGER) == DEBUG_SQLDEBUGGER)
{
require_once($opt['rootpath'] . 'lib2/sqldebugger.class.php');
parent::fetch($this->main_template . '.tpl', $this->get_cache_id(), $this->get_compile_id());
$this->clear_all_assign();
+10
View File
@@ -11,6 +11,8 @@
/***************************************************************************
Overview:
sql_enable_debugger() ... enables Sqldebug if not not already done by config
sql($sql) ... Query SQL and return result
sql_escape($value) ... Escape parameter for SQL-use
sql_escape_backtick($value) ... escape $value for use within backticks
@@ -79,6 +81,14 @@
$db['mode'] = DB_MODE_USER;
$db['error'] = false;
function sql_enable_debugger()
{
global $opt, $db;
$opt['debug'] |= DEBUG_SQLDEBUGGER;
$db['debug'] = true;
}
/*
sql("SELECT id FROM &tmpdb.table WHERE a=&1 AND &tmpdb.b='&2'", 12345, 'abc');
+18 -13
View File
@@ -11,7 +11,7 @@ $search_output_file_download = false;
function search_output()
{
global $opt;
global $db, $opt;
global $distance_unit, $startat, $count, $sql, $sqlLimit;
$encoding = 'UTF-8';
@@ -48,18 +48,21 @@ function search_output()
mysql_free_result($rsCount);
// start output
header("Content-type: application/xml; charset=".$encoding);
//header("Content-Disposition: attachment; filename=" . $sFilebasename . ".txt");
if (!$db['debug'])
{
header("Content-type: application/xml; charset=".$encoding);
//header("Content-Disposition: attachment; filename=" . $sFilebasename . ".txt");
echo "<?xml version=\"1.0\" encoding=\"".$encoding."\"?>\n";
echo "<result>\n";
echo "<?xml version=\"1.0\" encoding=\"".$encoding."\"?>\n";
echo "<result>\n";
echo " <docinfo>\n";
echo " <results>" . $rCount['count'] . "</results>\n";
echo " <startat>" . $startat . "</startat>\n";
echo " <perpage>" . $count . "</perpage>\n";
echo " <total>" . $resultcount . "</total>\n";
echo " </docinfo>\n";
echo " <docinfo>\n";
echo " <results>" . $rCount['count'] . "</results>\n";
echo " <startat>" . $startat . "</startat>\n";
echo " <perpage>" . $count . "</perpage>\n";
echo " <total>" . $resultcount . "</total>\n";
echo " </docinfo>\n";
}
$rs = sql_slave("SELECT `searchtmp`.`cache_id` `cacheid`,
`searchtmp`.`longitude` `longitude`,
@@ -154,12 +157,14 @@ function search_output()
$thisline = lf2crlf($thisline);
echo $thisline;
if (!$db['debug'])
echo $thisline;
}
mysql_free_result($rs);
sql_slave('DROP TABLE `searchtmp`');
echo "</result>\n";
if (!$db['debug'])
echo "</result>\n";
}