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 #183511 is a reply to message #183510] Tue, 29 October 2013 15:22 Go to previous messageGo to previous message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma:
Senior Member
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

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

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.

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

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
[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: Tue Nov 26 14:31:08 GMT 2024

Total time taken to generate the page: 0.06106 seconds