Re: Database abstraction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mensaje citado por Malte Starostik <malte.starostik@xxxxxxxxxxx>:

> Hi,
> 
> I've read several posts touching this subject, but I didn't find one that
> asks a simple question I've been wondering about since I first used PHP and
> that is also one of the two really really bad things about PHP (the other
> being lack of OO):

PHP5 deals with this.

http://ar.php.net/manual/en/faq.general.php#faq.general.relation-versions

> Why isn't there a DB abstraction layer right in PHP, so people writing some
> web app for redistribution don't have to care about the different DBs
> themselves?

Use PEAR::DB or PEAR::MDB.

> Why is there no modularization in this area, such that it'd be the _normal_
> way not to write things like $dbh = ibase_pconnect( ... ), but $dbh =
> sql_connect( "Firebird", ... )

With PEAR::DB all you have to do is build a string like this:

$dsn = "pgsql://username:password@hostspec/database_name";

And I will be running PostgreSQL so that later all I have to do is:

$db = DB::Connect($dsn);

$db->query("SELECT * FROM tabname");

> and that would internally check if a Firebird/InterBase driver is available
> and if so, use it.
> Surely there are some differences in SQL conformance and syntax extensions,
> but even that could be handled by such a layer to some extent.

See this:

http://pear.php.net/manual/en/package.database.db.intro-dsn.php

-- 
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
---------------------------------------------------------
Martín Marqués          |   Programador, DBA
Centro de Telemática	|     Administrador
               Universidad Nacional
                    del Litoral
---------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux