简体   繁体   中英

Manage pgsql exception in php

I use 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM