$show_sql = 0;
$go_debug = 1;
$pdf_debug = 0;
+ // set $sql_trail to 1 only if you want to perform bugtracking sql trail
+ // Warning: this produces huge amount of data in sql_trail table.
+ // Don't forget switch the option off and flush the table manually after
+ // trail, or your future backup files are overloaded with unneeded data.
+ //
+ $sql_trail = 0; // save all sql queries in sql_trail
+ $select_trail = 0; // track also SELECT queries
if ($go_debug == 1)
{
error_reporting(E_ALL);
function db_query($sql, $err_msg=null)
{
- global $db, $show_sql;
+ global $db, $show_sql, $sql_trail, $select_trail;
//echo "<br>$sql<br>";
if ($show_sql)
echo $sql;
echo "</pre>\n";
}
-
+
$result = mysql_query($sql, $db);
+ if($sql_trail) {
+ if ($select_trail || (strstr($sql, 'SELECT') === false)) {
+ mysql_query(
+ "INSERT INTO ".TB_PREF."sql_trail
+ (`sql`, `result`, `msg`)
+ VALUES(".db_escape($sql).",".($result ? 1 : 0).",
+ ".db_escape($err_msg).")", $db);
+ }
+ }
+
if ($err_msg != null)
if (function_exists('xdebug_call_file'))
check_db_error('<br>At file '.xdebug_call_file().':'.xdebug_call_line().':<br>'.$err_msg, $sql);
ALTER TABLE `0_suppliers` ADD `credit_limit` double NOT NULL DEFAULT '0' AFTER `tax_group_id`;
ALTER TABLE `0_chart_types` DROP INDEX `name`, ADD INDEX `name` ( `name` );
+
+DROP TABLE IF EXISTS `0_sql_trail`;
+
+CREATE TABLE IF NOT EXISTS `0_sql_trail` (
+ `id` int(11) NOT NULL auto_increment,
+ `sql` text NOT NULL,
+ `result` tinyint(1) NOT NULL,
+ `msg` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`)
+) TYPE = MyISAM;
+