X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb%2Fconnect_db.inc;h=dc2dd027ede11c4aadcb1acafbed14be6c8b30fa;hb=8864b1ec0fd3321e510511ef22614bc36845540e;hp=3fc2bcfb437a9a7bdcb270cd511bade59bbe5de1;hpb=f12dbe7523bb1abc6cd69b009ef8f0be838f5348;p=fa-stable.git diff --git a/includes/db/connect_db.inc b/includes/db/connect_db.inc index 3fc2bcfb..dc2dd027 100644 --- a/includes/db/connect_db.inc +++ b/includes/db/connect_db.inc @@ -1,6 +1,14 @@ . +***********************************************************************/ function set_global_connection() { @@ -18,8 +26,10 @@ $db_duplicate_error_code = 1062; function db_query($sql, $err_msg=null) { - global $db, $show_sql; - + global $db, $show_sql, $sql_trail, $select_trail, $go_debug; + + if (!$err_msg && $go_debug) + $err_msg = "Debug mode error"; //echo "
$sql
"; if ($show_sql) { @@ -28,9 +38,19 @@ function db_query($sql, $err_msg=null) echo $sql; echo "\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('
At file '.xdebug_call_file().':'.xdebug_call_line().':
'.$err_msg, $sql); @@ -46,6 +66,12 @@ function db_fetch_row ($result) return mysql_fetch_row($result); } +function db_fetch_assoc ($result) +{ + + return mysql_fetch_assoc($result); +} + function db_fetch ($result) { @@ -54,7 +80,7 @@ function db_fetch ($result) function db_seek (&$result,$record) { - mysql_data_seek($result, $record); + return mysql_data_seek($result, $record); } function db_free_result ($result)