Merged from MOODLE_14_STABLE - Better DB errors debug traces from Patrick Li
This commit is contained in:
+10
-10
@@ -66,7 +66,7 @@ function execute_sql($command, $feedback=true) {
|
||||
echo '<p><font color="red"><strong>'. get_string('error') .'</strong></font></p>';
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $command");
|
||||
}
|
||||
return false;
|
||||
@@ -446,7 +446,7 @@ function record_exists_sql($sql) {
|
||||
notify($db->ErrorMsg().'<br /><br />'.$sql);
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql");
|
||||
}
|
||||
return false;
|
||||
@@ -533,7 +533,7 @@ function count_records_sql($sql) {
|
||||
notify($db->ErrorMsg() .'<br /><br />'. $sql);
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql");
|
||||
}
|
||||
return 0;
|
||||
@@ -605,7 +605,7 @@ function get_record_sql($sql, $expectmultiple=false) {
|
||||
notify( $db->ErrorMsg() . '<br /><br />'. $sql . $limit );
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql$limit");
|
||||
}
|
||||
return false;
|
||||
@@ -790,7 +790,7 @@ function get_records_sql($sql) {
|
||||
notify($db->ErrorMsg() .'<br /><br />'. $sql);
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql");
|
||||
}
|
||||
return false;
|
||||
@@ -899,7 +899,7 @@ function get_records_sql_menu($sql) {
|
||||
notify($db->ErrorMsg() .'<br /><br />'. $sql);
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql");
|
||||
}
|
||||
return false;
|
||||
@@ -953,7 +953,7 @@ function get_field($table, $return, $field1, $value1, $field2='', $value2='', $f
|
||||
notify($db->ErrorMsg() .'<br /><br />SELECT '. $return .' FROM '. $CFG->prefix . $table .' '. $select);
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: SELECT $return FROM $CFG->prefix$table $select");
|
||||
}
|
||||
return false;
|
||||
@@ -988,7 +988,7 @@ function get_field_sql($sql) {
|
||||
notify($db->ErrorMsg() .'<br /><br />'. $sql);
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql");
|
||||
}
|
||||
return false;
|
||||
@@ -1146,7 +1146,7 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
|
||||
notify($db->ErrorMsg() .'<br /><br />'.$insertSQL);
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $insertSQL");
|
||||
}
|
||||
return false;
|
||||
@@ -1259,7 +1259,7 @@ function update_record($table, $dataobject) {
|
||||
notify($db->ErrorMsg() .'<br /><br />UPDATE '. $CFG->prefix . $table .' SET '. $update .' WHERE id = \''. $dataobject->id .'\'');
|
||||
}
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=end(debug_backtrace());
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: UPDATE $CFG->prefix$table SET $update WHERE id = '$dataobject->id'");
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user