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 #183524 is a reply to message #183523] Wed, 30 October 2013 00:12 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:

> 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 ) );

You have a different order of fetching the result and fetching the warnings.
Please try my test cases.

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

I have no idea.

The more important question is: Why would it matter *at* *all* in PHP 5.4.x
where by PDO_MySQL that attribute *is* *not* *supported* and *emulation*
*is* *not* *done* when using a MySQL 4.1+ client?

Something is utterly wrong with your local setup, and I assume it is at
least the MySQL version mismatch. First be clear which version of PHP,
MySQL client, and MySQL server you are using, *exactly*, and that you are
using the correct versions.

That said, why are you preparing invalid statements in the first place?


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
[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 Nov 28 14:08:46 GMT 2024

Total time taken to generate the page: 0.04673 seconds