Get an array in php mysql error like oci_error
Since some time ago I have been programming in php with oracle, and I've always liked the function oci_error()
because the function can give me the byte position of the error in the query (offset) and then I can make a function to show the error with a flag indicating where is the error in the query.
Well I'm making a similar function but with mysql:
I have the mysql_error()
which gives me the "message".
I have the mysql_errno()
which gives me the "code".
The "sqltext" I can get it with the function itself.
But, How can I get the offset value of the error in the开发者_运维百科 query?
MySQL errors are usually of the type
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near...
Following the "near" keyword is the part of the query where the error occurred. You could search for this string using strpos()
in your query and use that as the offset.
精彩评论