G
G
goodw842017-08-27 16:37:45
PostgreSQL
goodw84, 2017-08-27 16:37:45

How to catch database errors in PHP?

I use: PHP/CodeIgniter, PostgreSQL.
An error occurs in one of the INSERT queries:

A PHP Error was encountered
Severity: Warning
Message: pg_query(): Query failed: ERROR: Duplicate key value violates unique constraint "users_uk"
DETAIL: Key "(login)=(tester)" already exists.
Filename: postgre/postgre_driver.php
Line Number: 242

How is it cultural to intercept? And, if possible, report that a record with such a key already exists.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-08-27
@goodw84

https://stackoverflow.com/questions/7843406/codeig...

F
Furio, 2017-11-23
@Furio

It's all about the ENVIRONMENT constant in the index.php file .
In the development mode, absolutely all PHP errors are displayed.
Replace with
error_reporting(E_ALL & ~E_WARNING);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question