Skip to content

Commit 623be74

Browse files
committed
Display actual file and line number where the sql error is occured.
Make a change to display actual file and line number where the sql error is occured. When there is a sql error it will also display model file name where the error is occured.
1 parent a93bf2e commit 623be74

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

upload/system/database/mysql.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ public function query($sql) {
4747
return true;
4848
}
4949
} else {
50-
trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br />' . $sql);
50+
$trace = debug_backtrace();
51+
$caller = array_shift($trace);
52+
$caller = array_shift($trace);
53+
54+
trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br /> Error in: <b>' . $caller['file'] . '</b> line <b>' . $caller['line'] . '</b> <br/>' . $sql);
5155
exit();
5256
}
5357
}
@@ -77,4 +81,4 @@ public function __destruct() {
7781
}
7882
}
7983
}
80-
?>
84+
?>

0 commit comments

Comments
 (0)