3

I'm building a webapp for a department on a large college campus that will eventually be run on the enterprise servers ( I use the term 'enterprise' loosely ).

The problem is that the admins have refused to compile and enable any PDO extension other than SQLite. They do have mysql and mysqli enabled though, so it's not a total loss.

So does anybody out here know of a good ORM for PHP that does NOT rely on PDO as it's main engine?

I've already looked at Doctrine and Propel (both excellent frameworks), though could not figure out how to rip PDO out from inside them.

Edit: Here is the response I've gotten from the admins on the server:

Sean,

We have tried, unsuccessfully, several times to build PHP with the PDO extension included. The reason we haven't been successful is complicated, but basically stems from the fact that the web envoronment was originally set up with some database driver libraries compiled staticly and others compiled dynamically, the mix causing PDO to complain loudly. The reason things were were done this way was due to a bug in early versions of PHP 5.x that is no longer an issue today (or at least less of one), but switching is difficult because the change would require modifications to php.ini files and, since every site (including sites on [server redacted]) has its own php.ini (roughly 22,000 files total, many of which are modified by users) it is very difficult to push out that change (and not making the change causes errors [I don't recall if they are fatal or not] on pages served from accounts with non-updated files).

12
  • 2
    Why wouldn't you want to use PDO? It is the how you(future of) should connect to your database! Commented Jan 16, 2011 at 21:18
  • Well if you use Propel 1.0 (i think PDO came along in 1.2) it uses Creole as the abstraction instead of PDO (i think creole uses mysqli for mysql connectivity under the hood). In terms of Doctrine you would need to implement your own custom drivers - which im pretty sure would be no small feat given its complexity. Commented Jan 16, 2011 at 21:24
  • There exists a PDO emulation for PHP4, which also provides an alternative binding on PHP5. Link bottom right on xpdo.org - Though it would still require some rewriting to use it. And obviously that's also a substandard option. Commented Jan 16, 2011 at 21:26
  • 1
    Why would you ever NOT want PDO? Commented Jan 16, 2011 at 21:47
  • 1
    I LOVE PDO! The server this will be deployed on does not support PDO and the admins have refused to enable it. I'm stuck. Commented Jan 16, 2011 at 21:57

1 Answer 1

3

I suppose that every modern ORM relies on PDO as it's a standard database driver.

If you have MySQLi extension enabled then you should be able to write your own PDO (IIRC MySQLi supports everything that PDO does).

if (extension_loaded('pdo_mysql') == false) { class PDO { protected $connection; public function __construct($dsn, $username = null, $password = null, array $driver_options = array()) { $this->connection = new MySQLi(...); } } class PDOStatement { ... } class PDOException extends RuntimeException { ... } } 

You'll have to implement whole PDO API but at least it will works.

Sign up to request clarification or add additional context in comments.

2 Comments

Now I'm not sure how similar mysqli and PDO interfaces are. But if some functions are named the same and take the same arguments you could use the above approach together with the __call magic method to pass on calls to the mysqli object indtance. Then you would not have to implement the entire PDO interface but just the functions that differs in name and/or arguments.
I think this is ultimately what I'll go with. Thanks for all the help guys.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.