Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #11621
| Message-ID | <12356089.gSGYd4PIy3@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-10-29 13:10 +0100 |
| Subject | Re: PDO - Cannot retrieve warnings with emulated prepares disabled |
| Newsgroups | comp.lang.php |
| References | <l4mohq$9ea$1@news.albasani.net> |
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@news.demon.co.uk>
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PDO - Cannot retrieve warnings with emulated prepares disabled Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2013-10-28 23:30 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-29 13:10 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Tim Streater <timstreater@greenbee.net> - 2013-10-29 12:23 +0000
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2013-10-29 13:31 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-29 13:47 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2013-10-29 16:26 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-29 19:19 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Jerry Stuckle <jstucklex@attglobal.net> - 2013-10-29 15:55 -0400
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-29 21:06 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Jerry Stuckle <jstucklex@attglobal.net> - 2013-10-29 20:57 -0400
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Christoph Michael Becker <cmbecker69@arcor.de> - 2013-10-30 02:59 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Jerry Stuckle <jstucklex@attglobal.net> - 2013-10-29 22:04 -0400
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Jerry Stuckle <jstucklex@attglobal.net> - 2013-10-29 08:58 -0400
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2013-10-29 16:22 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Jerry Stuckle <jstucklex@attglobal.net> - 2013-10-29 16:09 -0400
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-29 21:50 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Jerry Stuckle <jstucklex@attglobal.net> - 2013-10-29 21:01 -0400
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2013-10-29 23:11 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-30 01:12 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2013-10-30 15:38 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Jerry Stuckle <jstucklex@attglobal.net> - 2013-10-29 21:10 -0400
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2013-10-30 15:51 +0100
Re: PDO - Cannot retrieve warnings with emulated prepares disabled Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2013-10-30 21:09 +0100
csiph-web