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 #183513 is a reply to message #183512] Tue, 29 October 2013 18:19 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:

> Thomas 'PointedEars' Lahn schrieb:
>> I presume reading the changelog will tell.
>
> I couldn't find anything relating to this issue there.

Too bad. UTSL?

>>>> PDO::ATTR_EMULATE_PREPARES == false should be the effective default for
>>>> PDO_MySQL unless you are using an ancient MySQL version (why?) that
>>>> does not support Prepared Statements.
>>> My MySQL version does support them. Still, PDO's default seems to be
>>> "on" for the emulation.
>>
>> Not here; the attribute is not even supported:
>>
>> $ php -r '
>> $pdo = new PDO("mysql:host=localhost", "…", "…");
>> var_dump($pdo->getAttribute(PDO::ATTR_EMULATE_PREPARES));'
>> PHP Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not
>> support this function: driver does not support that attribute in Command
>> line code on line 3
>> PHP Stack trace:
>> PHP 1. {main}() Command line code:0
>> PHP 2. PDO->getAttribute() Command line code:3
>> bool(false)
>
> Yes, I get that error too -- which is all the more confusing, since
> otherwise the behaviour with PDO::ATTR_EMULATE_PREPARES == false is
> consistent with the assumption that prepared statements are indeed
> supported. See my reply to Jerry.

Both Jerry and you are wrong.

Prepared statements have been supported in MySQL since version 4.1 (as you
can read in the MySQL manual), and with the “pdo_mysql” extension since its
first version (as you can read in the PHP manual). Naturally, therefore
they have always been supported with the “mysql” and “mysqli” extensions
*too*, provided your MySQL client library and the MySQL server accessed with
it were recent enough.

Jerry is also confusing “mysql”, “mysqli”, and “pdo_mysql”, which are
*separate* extensions (you are using the latter). *You* are confusing the
MySQL client (library) – that is *used by* a database driver – with a
database driver (for PHP).

“pdo_mysql” is a PHP extension that provides a PDO driver (a database-
specific driver that implements the PDO interface as provided by the “pdo”
PHP extension); “mysql” and “mysqli” are PHP extensions that provide only
MySQL drivers.

“pdo_mysql” does _not_ use nor require either the “mysql” or the “mysqli”
extension. As a result, if you have “pdo_mysql” loaded (which is only
possible if you load “pdo” first), and no applications on your server that
use the mysql*_* functions/methods, you can disable the other two without
your applications that use “pdo_mysql” stopping to function. BTDT.

PHP extensions:

<<provides>>
mysql ----------------> driver --------.
(deprecated/obsolete) : <<uses>>
:
<<provides>> <<uses>> v <<accesses>>
mysqli ------------> driver <---> MySQL client -------------> MySQL server
(library)
^
<<provides>> : <<uses>>
pdo_mysql ------------> driver --------'
|
| <<implements>>
|
<<provides>> v
pdo --------------------> PDO
(data-access layer = interface)

You and I get the _warning_ above because, as you can read in the PHP
manual, “pdo_*mysql*” (at least in version 5.4.x) does not need/support that
attribute; when it detects that the MySQL client version is that old that it
does not support prepared statements, and you are using PDO::prepare(), it
will emulate them automagically.

However, as you can also read in the PHP manual, since PHP 5.4.0 MySQL
versions older than 4.1 are no longer supported by “pdo_mysql”, so there
will never be emulation of Prepared Statements with “pdo_mysql” in PHP 5.4+;
it is unnecessary.

I do not for sure know why, with PHP 5.4.x, you are getting different
results with and without setting the attribute. Maybe it has to do with the
fact that you are using a MySQL 5._0_ client library to access a MySQL 5._1_
server.

If that is not the reason, it could be either a flawed test case or a PHP
bug; if you can still reproduce it after synchronizing the MySQL client
versions with the server version, try upgrading to the latest stable version
of PHP 5.4.

BTW, MySQL 5.1.x was first released in 2005-11; it is in the
Extended/Sustaining Support phase now (IIUC, you have to pay for updates).
MySQL Server CE 5.1.41 was GA-released on 2009-11-05; the latest version is
5.1.72, GA-released on 2013-09-20.


HTH

PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(at)news(dot)demon(dot)co(dot)uk> (2004)
[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:28:29 GMT 2024

Total time taken to generate the page: 0.04369 seconds