Tag Archives: PDO

If I was the Zend CTO

This is just my opinion working every day with PHP for many purposes since 7 years.

PS: Surely also SOAP support needs attention but it seems they’re working on it.

Redundancy in PHP DB drivers

Once upon a time PHP had several different DB drivers such as:

  • mysql
  • pgsql
  • mssql
  • oci
  • sqlite
  • odbc
  • informix
  • firebird

Later came

  • mysqli
  • oci8

and we already had duplicated drivers (also if they have some different optimizations/features)

Later came PDO and we had

  • pdo_mysql
  • pdo_pgsql
  • pdo_mssql
  • pdo_oci
  • pdo_oci8
  • pdo_sqlite
  • pdo_odbc
  • pdo_informix
  • pdo_firebird

so now we have 4 drivers only for oracle (oci, oci8, pdo_oci, pdo_oci8) and 3 for mysql (mysql, mysqli, pdo_mysql) and anyway every driver is at least duplicated.

I don’t think this is the right way to go on, if PDO is here to remain, first all bugs in pdo should be solved and PDO features should reflect the single driver feature (I wrote about about that yesterday), then old drivers should be removed. Duplicated oci/oci8 driver should be unified too.

Now the situation is confusing and it’s difficult to test things against different drivers, tracking and solving bugs.

A big lack in PHP PDO

It seems to me that none in the world needs to get meta-info from a query like this:

SELECT * FROM table1 JOIN table2 ON (table1.id=table2.id)

I need to know from which table are the returned columns from. That’s not possible. It was possible with some old PHP DB drivers (not for all and I can’t understand why) but it’s not possible with PDO (and also Zend_DB does strange things about that but it’s very limited).

Let’s look at the situation, PDO has the PDOStatement->getColumnMeta() method but:

  • This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.
  • Not all PDO drivers support PDOStatement->getColumnMeta().
  • withit the returned data there isn’t the table name

I filled a bug some time ago and some developer add that feature for MySQL but they don’t understand that it’s needed for every DB adapter and it was already done by some old functions.

Maybe no PHP developer need such kind of abstraction.