Today the site appears a bug, and then directly in the database class to write the log, to see which SQL is a problem, the SQL statement to is found, but do not know where the SQL statement came from, so I would like to, if there is a way to see how this method is currently running is called by which method, And which method is called by the previous method, and so on, it is good to find the entry address. But I have thought about it before, also in the Internet to search, is not found the relevant method, today a colleague (senior) said that the Java debugging is very common, called this stack debugging, I was on the Internet search PHP stack. I found it, and then I wrote my own way.
//call the Stack function to find the source of the calling function for easy debuggingfunctionPrint_stack_trace () {$array=Debug_backtrace(); //Print_r ($array);//information is complete unset($array[0]); foreach($array as $row) { $html.=$row[' file ']. ': '.$row[' line ']. ' Line, caller: '.$row[' function ']. <p> "; } return $html;}
I call this method inside the core query function of my database and print the result as follows:
d:\wamp\www\meilele\includes\cls_mysql.php:471 line, call method:queryd: \wamp\www\meilele\includes\cls_mysql.php : 507 lines, call method:getalld: \wamp\www\meilele\includes\lib_common.php:732 line, call method:getallcachedd: \wamp\ Www\meilele\includes\init.php:113 line, call method:load_configd: \wamp\www\meilele\index.php:4 line, call method:Include_ Once
At a glance, has been found the entrance, too tough. There's one more way to debug later.