Manage pgsql exception in php
I use开发者_JS百科 Postgres DB 8.4, PHP 5 and php5-pgsql. How can I handle pgsql exceptions and sql error code? I read that php library does not handle pgsql error codes.
I read that php library does not handle pgsql error codes.
Who told you that? That person has never read any manual because PHP has great support for error handling in combination with PostgreSQL and it's all in the fine manual.
Use pg_result_error() and you will see that you get all the details about what happend. If you're using stored procedures and these throw custom error messages and/or hints to solve the problem, you will get these as well.
The error codes you will catch, can be found in the PostgreSQL manual.
精彩评论