Instead of sending queries to PHPs mysql_query() function I currently send my queries to a custom wrapper sql_query(), which, amongst other things does the “mysql_query” part.
The problem with this setup is that when there’s an SQL error the file and the line number are where the sql_query() function is located, rather then where the actual SQL query is.
Is there a way of having PHP report the file and linenumber of where sql_query() is called from, rather than where the mysql_query() function actually is?
debug_backtrace
And many helpful example there for your problem. One of this.
Surprisingly, no one has described one of the best uses of this: dumping a variable and showing the location. When debugging, especially a big and unfamiliar system, it’s a pain remembering where I added those var dumps. Also, this way there is a separator between multiple dump calls.