X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb%2Fconnect_db.inc;h=fd6870e947ed121d58ec558a13a00561b523c3f5;hb=8110c7a16ca343e6a48658db2ab95a573e22118f;hp=f65ddb4537b0b7167d23622db351274219602465;hpb=2489ca7e5fc4414b7b70132a23090fd687af5f1b;p=fa-stable.git diff --git a/includes/db/connect_db.inc b/includes/db/connect_db.inc index f65ddb45..fd6870e9 100644 --- a/includes/db/connect_db.inc +++ b/includes/db/connect_db.inc @@ -1,6 +1,14 @@ . +***********************************************************************/ function set_global_connection() { @@ -18,8 +26,8 @@ $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; + //echo "
$sql
"; if ($show_sql) { @@ -28,15 +36,26 @@ function db_query($sql, $err_msg=null) echo $sql; echo "\n"; } - + $result = mysql_query($sql, $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); - else - check_db_error($err_msg, $sql); + 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 || $go_debug) { + $exit = $err_msg != null; + if (function_exists('xdebug_call_file')) + check_db_error('
At file '.xdebug_call_file().':'.xdebug_call_line().':
'.$err_msg, $sql, $exit); + else + check_db_error($err_msg, $sql, $exit); + } return $result; } @@ -46,6 +65,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 +79,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) @@ -75,12 +100,10 @@ function db_num_fields ($result) function db_escape($value = "", $nullify = false) { - $value = htmlspecialchars($value, ENT_COMPAT, $_SESSION['language']->encoding); + $value = @htmlspecialchars($value, ENT_COMPAT, $_SESSION['language']->encoding); //reset default if second parameter is skipped $nullify = ($nullify === null) ? (false) : ($nullify); - //undo slashes for poorly configured servers - $value = (get_magic_quotes_gpc()) ? (stripslashes($value)) : ($value); //check for null/unset/empty strings if ((!isset($value)) || (is_null($value)) || ($value === "")) {