Re: PDO - Cannot retrieve warnings with emulated prepares disabled [message #183511 is a reply to message #183510] |
Tue, 29 October 2013 15:22 |
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)
|
|
|