This time is learning PostgreSQL, I use the PDO mode to operate, connection, increase and remove the check can be normal operation, but found that all the wrong statements will not be error, such as in MySQL an error SQL will directly interrupt and output error messages and error numbers, But PostgreSQL just give the result to a false value, no information and hints, do not know whether it is because of the SQL syntax problem, there is a transaction, there is an error in SQL execution, and finally actually executed successfully ... No catch-out error.
Not clear is where I configure the problem or the operation of the wrong way, I hope to have an understanding of friends can click, thank you!
Reply to discussion (solution)
PostgreSQL does not give error numbers and error messages? This is obviously impossible, but you don't know how to check for errors.
PDO uses two ways to provide error messages:
1. Returns an array using the ErrorInfo method
Array
0 = SQLState error code for ANSI SQL standard
1 = error code defined by the database you are using
2 = error message defined by the database you are using
}
You can determine if there is any error by checking the first
This is the default way for PDO
2. Specify the use exception throw mechanism by setting the value of the property entry Pdo::attr_errmode to Pdo::errmode_exception
try {//Do various database operations here} catch (Pdoexception $e) {die ("error!:". $e->getmessage (). "\ n");}
In fact, the manual is very clear, but you do not read it carefully
PostgreSQL does not give error numbers and error messages? This is obviously impossible, but you don't know how to check for errors.
PDO uses two ways to provide error messages:
1. Returns an array using the ErrorInfo method
Array
0 = SQLState error code for ANSI SQL standard
1 = error code defined by the database you are using
2 = error message defined by the database you are using
}
You can determine if there is any error by checking the first
This is the default way for PDO
2. Specify the use exception throw mechanism by setting the value of the property entry Pdo::attr_errmode to Pdo::errmode_exception
try {//Do various database operations here} catch (Pdoexception $e) {die ("error!:". $e->getmessage (). "\ n");}
In fact, the manual is very clear, but you do not read it carefully
Really should read the manual carefully, thank you very much moderator