Hi Gabriele. That sort of dynamic ORM is something I've been working on as well, but absolutely requires PHP 5. That means we can't really consider it for Drupal for another year at least. :-( PDO is *not* meant to be a complete DB abstraction; it's an API unification. I'm writing it as a new backend for Drupal as an alternative to mysql and pgsql APIs, because it should be faster than our own prepared statement support. Hopefully it will also make Oracle et al easier to support, as then there's only one set of PHP calls needed. Eventually, when PHP 4 goes away the separate DB backends can go away, too. And yes, db_num_rows() is now on my hit list. :-) On Saturday 07 April 2007 4:12 am, Gabriele Turchi wrote:
Currently I'm doing an experimental Oracle port, and for that need I've done a quick travel in the drupal code...
Frankly, I don't think PDO could be a solution for a better database portability, at least in drupal.
From what I've seen, the database usage is pretty plain (some "create" in ".install" and mostly simple (only some table involved) "select", "insert" and "update" - or, better, "upsert" in the code).
My first feeling was to create a very light db persistence layer, based on php dynamic object creation (__get and __set): define a class with an array on info like: name, type (number, text, large text and blob), is (part of) primary key, is indexable. Do a mapping into a "create table" should be easy.
The actual common usage of "db_fetch_object" may be left more or less unchanged, simply creating queries asking what fields from what table with what filters. The "join" case can be simplifyed using views.
About the db_num_rows question: there are more than a good reason to avoid it. As an example, the default behavior for the postgresql driver is to fetch in memory _all_ the results before returning the first one to the caller: with big tables this is simply devastating (and can be removed from future releases). And Oracle simply doesn't support it.
My 2cents...
Best Regards, Gabriele Turchi
P.S.: I'm sorry, my english il alpha version...
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson