Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Davey Shafik's Blog:
Extending PDO a Waste...
Sep 22, 2005 @ 11:29:31

In this latest blog entry from his site, Davey Shafik talks about some troubles that one of the PDO changes that were made the other day concerning contructor overloading.

I just spent some time writing a test script to compare using PDO by extending it, and by proxying it using __call(). Let me start out by saying, when I first wrote Crtx_DB, I extended PDO, this meant you could easily fall back to native PDO calls if the Crtx_DB_DataObject CRUD automaticn wasn't working for you, without needing to instantiate another object.

Then it was decided that PDO::__construct() would be made final because if a user extended PDO and overwrote __construct() without calling parent::__construct() it caused PHP to segfault (or otherwise do bad things).

A couple of days ago, Ilia announced that the ability to extend PDO and overwrite PDO::__construct() has not been restored.

He did some testing on extending PDO versus using __call() to make the sam types of requests and found some interesting results:

Extending PDO Vs using __call() to proxy it, is approximately 5.5% slower on average, what this means is, using __call() 100 times is slower than creating 100 new database connections.

tagged:

Link:


Trending Topics: