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 #183519 is a reply to message #183511] Tue, 29 October 2013 20:09 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 11:22 AM, Thomas Mlynarczyk wrote:
> Jerry Stuckle schrieb:
>
>> I could be wrong, but from my experience, the mysql driver has never
>> supported prepared statements, while the mysqli driver has always
>> supported them. This is why PDO has to emulate the prepared statements.
>
> This is what PDO tells me about the driver being used:
> PDO::ATTR_CLIENT_VERSION => mysqlnd 5.0.10 - 20111026
>

Ok, so you're using MySQL's driver for PHP 5.4+. That's good; it
supports everything.

>> If you disable emulation with a mysql connection, I would expect
>> errors in the execution. What is the return value from your prepare()
>> and execute() calls?
>
> Prepare() returns a PDOStatement object and execute returns true.
>

Yea, I though about the prepare() - if it didn't return a PDOStatement
object your execute() call would get a fatal exception ($stmt not an
object). But I'm surprised that the execute() call returns true.

> Everything works fine with PDO::ATTR_EMULATE_PREPARES == false (except
> for the issue with SHOW WARNINGS) and consistent with the assumption
> that prepared statements are indeed supported.
>
> $pdo->prepare( 'invalid' ) will return false; with emulated prepares it
> will return a PDOStatement object -- both as expected.
>

That part is as it should be.

> With emulated prepares,
>
> $stmt = $pdo->prepare( 'SELECT * FROM mytable LIMIT ?' );
> $stmt->execute( [ 4 ] );
>
> will give me a syntax error complaining about "LIMIT '4'", whereas with
> PDO::ATTR_EMULATE_PREPARES == false the query works fine (proving that
> the ? placeholder was indeed replaced with (int) 4 instead of (string) '4'.
>
> Greetings,
> Thomas
>

If anything, I would have expected the opposite to be true - works with
emulation but not with PDO::ATTR_EMULATE_PREPARES == false, but that's
only because I think PDO has a bit more flexibility in preparing
statements. I could be wrong, though.

Do you get a result from the 'Select 5 + "Five"'? If so, what is it?

Also, what happens if you try "Select 5 + 'Five'"? (note different quoting).

I'm beginning to think you've found a bug in the PDO extension, but I'm
not sure (yet).

--
==================
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: Thu Sep 19 22:01:32 GMT 2024

Total time taken to generate the page: 0.05283 seconds