In the class constructor for working with the database I set the attribute

$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); 

However, no errors are displayed (although they exist).

In particular

 $sql = "select count(*) from `punbb_users` where `username` = ? limit 1"; $params = 'somebody'; $stmt = $this->pdo->prepare($sql); $stmt->execute($params); 

It does not give an error, although it does not execute, since $params is not an array.

What could be the problem? (other warnings are displayed, that is, their output mode is enabled).

    1 answer 1

    It is better to enable exception mode.

     <?php $pdo = new PDO( 'mysql:host=localhost;dbname=test', 'root', '', [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); 
    • and catch them try { }catch(Exception $error) {} - Naumov
    • I figured out the output of warnings - my jamb was there (the mode of issuing warnings was still not turned on, or disconnected somewhere along the way of life), but I could not make an exception on your advice. Also, as I understood it, even if I didn’t install anything , warnings are still displayed. Could it be that something in some kind of global settings does not allow throwing exceptions? That is, it turns out that this attribute setting does not affect anything at all. - RussCoder