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 #183517 is a reply to message #183513] Tue, 29 October 2013 19:55 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 2:19 PM, Thomas 'PointedEars' Lahn wrote:
> 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.
>

I was not discussing the pdo_mysql extension. I was discussing the
mysql_extension - which does NOT support prepared statements. And
pdo_mysql in PHP 4.1 only emulated prepared statements; it did not
support the MySQL version of prepared statements directly.

> Jerry is also confusing “mysql”, “mysqli”, and “pdo_mysql”, which are
> *separate* ext ensions (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).
>

No, I am not. If I had meant pdo_mysql, I would have SAID pdo_mysql.

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

Wow - you can copy and paste!

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

You mean the PDO authors wrote their own mysql client library?
Interesting that they would go to all that trouble when the MySQL client
library is readily available for use. It is also debugged and changes
as necessary with MySQL versions.

Glad I don't use PDO.

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

Who cares about old versions? Nothing in his update says he's using an
old version.

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

Maybe you're not sure because you don't know anything.

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

Don't let the point on your head puncture your colon.

--
==================
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: Sat Nov 30 00:03:48 GMT 2024

Total time taken to generate the page: 0.04868 seconds