FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PDO - Cannot retrieve warnings with emulated prepares disabled
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: PDO - Cannot retrieve warnings with emulated prepares disabled [message #183506 is a reply to message #183501] Tue, 29 October 2013 12:10 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Thomas Mlynarczyk wrote:

> 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?

I cannot reproduce that.

---------------------------------------------------------------------------
$ php -r '
$pdo = new PDO("mysql:host=localhost", "…", "…");
$stmt = $pdo->prepare("SELECT 5 + \"Five\"");
$stmt->execute();
var_dump($pdo->query("SHOW WARNINGS")->fetchAll(PDO::FETCH_ASSOC));
var_dump($stmt->fetchAll());'
array(1) {
[0] =>
array(3) {
'Level' =>
string(7) "Warning"
'Code' =>
string(4) "1292"
'Message' =>
string(40) "Truncated incorrect DOUBLE value: 'Five'"
}
}
array(1) {
[0] =>
array(2) {
'5 + "Five"' =>
string(1) "5"
[0] =>
string(1) "5"
}
}

$ php -r '
$pdo = new PDO("mysql:host=localhost", "…", "…");
$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));
var_dump($stmt->fetchAll());'
array(1) {
[0] =>
array(3) {
'Level' =>
string(7) "Warning"
'Code' =>
string(4) "1292"
'Message' =>
string(40) "Truncated incorrect DOUBLE value: 'Five'"
}
}
array(1) {
[0] =>
array(2) {
'5 + "Five"' =>
string(1) "5"
[0] =>
string(1) "5"
}
}

$ php -v
PHP 5.4.15-1 (cli) (built: May 12 2013 12:17:45)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with XCache v3.0.1, Copyright (c) 2005-2013, by mOo
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
with XCache Optimizer v3.0.1, Copyright (c) 2005-2013, by mOo
with XCache Cacher v3.0.1, Copyright (c) 2005-2013, by mOo
with XCache Coverager v3.0.1, Copyright (c) 2005-2013, by mOo

$ mysql -V
mysql Ver 14.14 Distrib 5.5.33, for debian-linux-gnu (i686) using readline
6.2
---------------------------------------------------------------------------

PDO::ATTR_EMULATE_PREPARES == false should be the effective default for
PDO_MySQL unless you are using an ancient MySQL version (why?) that does not
support Prepared Statements.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: splitting list into columns
Next Topic: reading files with accents in the filename from PHP
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Sep 19 17:06:04 GMT 2024

Total time taken to generate the page: 0.04330 seconds