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 #183529 is a reply to message #183523] Wed, 30 October 2013 01:10 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 10/29/2013 6:11 PM, Thomas Mlynarczyk wrote:
> Jerry Stuckle schrieb:
>
>> Do you get a result from the 'Select 5 + "Five"'? If so, what is it?
>
> Yes, I get a result -- see below. I did some more testing:
>
> $pdo = new PDO( 'mysql:...', '...', '...' );
> var_dump( $pdo->setAttribute( PDO::ATTR_EMULATE_PREPARES, false ) );
> var_dump( $stmt = $pdo->prepare( 'SELECT 5 + "Five"' ) );
> var_dump( $stmt->execute() );
> var_dump( $stmt->fetchAll( PDO::FETCH_ASSOC ) );
> var_dump( $pdo->query( 'SHOW WARNINGS' )
> ->fetchAll( PDO::FETCH_ASSOC ) );
>
> Return values with PDO::ATTR_EMULATE_PREPARES = false:
> setAttribute -> true
> prepare -> PDOStatement
> execute -> true
> fetchAll -> array( '5 + "Five"' => (float) 5 )
> SHOW WARNINGS -> (empty array)
>
> Return values with PDO::ATTR_EMULATE_PREPARES = true:
> setAttribute -> true
> prepare -> PDOStatement
> execute -> true
> fetchAll -> array( '5 + "Five"' => (string) '5' )
> SHOW WARNINGS -> array with warning
>
> Results are the same with PHP 5.4.8 and PHP 5.4.21. Note the different
> return types of the value 5 -- float vs. string. This surprises me a
> little -- why would the setting for emulation of prepared statements
> influence the *returned* data?
>
>> Also, what happens if you try "Select 5 + 'Five'"? (note different
>> quoting).
>
> No change.
>
>> I'm beginning to think you've found a bug in the PDO extension, but
>> I'm not sure (yet).
>
> Hm. I tested with PHP 5.4.8 and 5.4.21 and it didn't work. But it
> obviously worked with PHP 5.4.15 as both Thomas Lahn's and my own test
> on a different server have shown. In both cases, MySQL 5.5 is involved
> whereas my local system is still on MySQL 5.1.41. This leads me to think
> that it's not (or at least not entirely) a PDO issue.
>
> Greetings,
> Thomas
>

Thomas,

I'm not sure it isn't a PDO issue. Just because it worked with MySQL
5.5 and didn't with MySQL 5.1.41 is not entirely conclusive. Only if
there was a change in the error/warning handling between MySQL 5.1.41
and 5.5 would it be entirely MySQL.

I might recommend you check the change logs for MySQL between 5.1.41 and
5.5. Alternately, you could follow up on comp.databases.mysql and see
if there is a change. This would help determine if a change in MySQL
accounts for your difference in processing.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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: Sun Nov 24 20:23:12 GMT 2024

Total time taken to generate the page: 0.05288 seconds