On Mar 28, 2004, at 14:06, Evan Prodromou wrote:
"MM" == Magnus Manske magnus.manske@web.de writes:
MM> I suggest putting *all* current queries into a new MySQL PHP MM> class. A new database can then be added by "simply" rewriting MM> that class.
Why not use an existing database abstraction layer, like ADOdb?
I believe what Magnus is suggesting is abstracting the *queries*, not the database's API, which we already do. For instance, where we now use our existing roll-your-own database API layer to do something like:
$ns = $title->getNamespace(); $t = wfStrencode( $title->getDBkey() ); $id = wfQuery( "SELECT cur_id FROM cur WHERE cur_namespace=$ns AND cur_title='$t'", DB_READ );
we would do something like this:
$id = $wgDatabase->getArticleId( $title );
where the database class would contain the actual SQL query. I'm not sure to what extent this is necessary or desirable; my preference would be to consider SQL to be our query abstraction layer already, and just try harder than we do now to have well-factored code that keeps queries contained in the classes that deal with that particular type of data. Even now we do:
$id = $title->getArticleId();
and keep the SQL for it tucked away in the Title object (or actually in LinkCache).
For the most part, database-specific SQL should only be happening in install and upgrade phases, or with more exotic features like full-text search.
-- brion vibber (brion @ pobox.com)