What does setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION) do more exactly?
Asked Answered
B

1

5

As the title says, i tried to understand the concept but it seems like with it or without it the result its the same. I tried to look into php manual and i kind of understand what says but in practice its just seems the result is the same.

enter image description here

Baily answered 21/4, 2018 at 19:21 Comment(0)
D
6

Manual also says that

PDO::__construct() throws a PDOException if the attempt to connect to the requested database fails.

This is your case exactly. And it has nothing to do with PDO::ERRMODE_EXCEPTION.

To test PDO::ERRMODE_EXCEPTION - properly connect to an existing database and run an invalid query.

Dastard answered 21/4, 2018 at 19:30 Comment(2)
Thank you , i tested it on a query with and without setattrib and now i can see the difference .Baily
PDO error modes as a reference php.net/manual/en/pdo.error-handling.phpAeronautics

© 2022 - 2024 — McMap. All rights reserved.