0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, pg_send_query() and pg_result_error_field() is exactly what I wanted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.