PDO - Cannot retrieve warnings with emulated prepares disabled [message #183501] |
Mon, 28 October 2013 22:30 |
Thomas Mlynarczyk
Messages: 131 Registered: September 2010
Karma:
|
Senior Member |
|
|
When I do this:
$pdo = new PDO( /* MySQL connection */ );
// $pdo->setAttribute( PDO::ATTR_EMULATE_PREPARES, false );
$stmt = $pdo->prepare( 'SELECT 5 + "Five"' );
$stmt->execute();
var_dump( $pdo->query( 'SHOW WARNINGS' )
->fetchAll( PDO::FETCH_ASSOC ) );
I get a warning back:
Warning 1292 Truncated incorrect DOUBLE value: 'Five'
But when I uncomment the second line (disabling emulation of prepared
statements), "SHOW WARNINGS" returns an empty array. Why?
How can I get warnings and notices from MySQL in that case? PDO doesn't
seem to offer a method for retrieving them -- only for errors.
Greetings,
Thomas
--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
|
|
|