AW: [PEAR-DEV] Re: Some thoughts about abstraction layers

From: Date: Thu, 29 Nov 2001 22:27:08 +0000
Subject: AW: [PEAR-DEV] Re: Some thoughts about abstraction layers
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-3207@lists.php.net to get a copy of this message
Hi there, > > > > +----------------------------------------------+ > > > | Informationobjects | > > > +----------------stored in---------------------+ > > > | Informationcontainer | > > > +---------------which could be-----------------+ > > > | Datacontainers like | > > > | RDBMS |OODBMS|LDAP|File| > > > +------access data by---------+......+....+....+ > > > | SQL | API-Calls| > > > +-------from-------+---on-----+ > > > | physical container | > > > +--------------like-----------+ > > > |MySQL|ORACLE|MSSQL|..........| > > > +-----+------+-----+----------+ > > $handle = DataContainer::factory( "RDBMS", "MySQL") ; > $condition = array( "id", "gt", 12, array( "AND", array( > "time", "lt", > "103902326"))) ; > $resultset = $handle -> SQL -> select( "table1", $columns, $condition) ; > $resultset = $handle -> API -> query( "SELECT $columns FROM > table1 WHERE id < > 12 AND time > 103902326") ; > IMHO this is exactly the way one could/should do this. (it looks quite like something I realized for my current project ;-)) ) For (my) normal needs the 'datacontainer'-thing fits almost all the time. I don't think you'll need 'true' DB-Abstraction in most of db-driven apps. A way to build SQL-Statements from some parameters to have a layer between your 'real' programm-logic and the classes which does the 'dirty' data-digging work form the db seems to be enough (work for developers *g*). So if you switch the the db but keep most of your table-structure you just have to change those classes. To be safe against changing the SQL-Tables in the DB I've build a class which 'abstracts' them in assoc-arrays, so i hope i can completley change the way data is stored (files, oodb) and can still use the same methods in my 'buisness-logic'. It works for me (i hope), but of course metabase is much more flexible and has a broader approach to do such thing - but i think it's much more complex, too. Just some thoughts of quite a newbie *g* (just tell me to be quiet if experts talk - and i'll be *g*) Bye Karsten

« previous php.pear.dev (#3207) next »