mysql 5.1 signal an error to cause PDO exceptions
I know mysql 5.5 allows using SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Error: ...'; to raise a user defined error. And this error will stop an INSERT operation if it was put in the BEFORE INSERT TRIGGER on some tables. And it's also convenient for PDO to catch the PDOException and output the errorinfo() i.e. MESSAGE_TEXT defined in SIGNAL SQLSTATE. However, the version of mysql on the server I rent is mysql 5.1. And I want to know how can I raise a user defined error with the features like the SIGNAL SQLSTATEMENT in mysql 5.5.
- interrupt a insert operation when it's in before insert trigger
- can be caught by PDO
I've found some topics on similar problems, and I've tried these:
call a nonexist procedure
use a function to throw an error
Both can't be caught by PDO. So what's a solution? ( I tested on MySQL5.5 )