Jump to content

PDO error reporting


Mudsaf
 Share

Recommended Posts

Hello, i've tried to learn bit PDO connections but i'm wondering how the error checking works.

 

Example my code.

$con->exec("INSERT INTO first_example (value) VALUES ('2')") or die("LOL");

So basically the code above works? Anyone have good tutorials for PDO & is it that hard to learn PDO if i can do MySQL?

Link to comment
Share on other sites

There are three type of error mode in PDO silent (default),exception,traditional php error. silent will not show any error you need to use PDO::errorInfo() and PDO::errorCode(). traditional php error will show php warning and errors. and exception mode will throw exception which can be caught in between anywhere in call stack.

to change the error mode attribute you need to use PDO::setAttribute()

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...