When I recently used thinkphp to find an error message that could not capture MySQL, such as inserting a primary key duplicate data into a table, the program is stuck on that statement as follows
:(
SQLSTATE[23000]: Integrity constraint violation:1062 Duplicate entry ' 1 ' for key ' PRIMARY 'Wrong location
file:d:\*****\thinkphp\library\think\db\driver.class.php line:226
TRACE
#0 d:\*****\thinkphp\library\think\db\driver.class.php (226): Pdostatement->execute ()
Invalid using try catch in code, last modified Driver.class.php file
In 169 rows and 226 rows.
$result = $this->pdostatement->execute ();
Revision changed to
Try{Lighthouse
$result= $this -pdostatement->execute ();
}Catch(\pdoexception$e) {
Echo' querystr= '.$this -Querystr.' <br/> ';
Print"Error:". $e->getmessage ()."<br/>";
return-1;
}
This gives you the flexibility to handle PDO errors, and of course the code that displays the error message can be changed to send an email to the administrator, or to log functions.
This method changes the bottom of the frame, and later upgrades will be more troublesome. Any friend who has a better way is also kindly advised.
thinkphp getting MySQL errors