Blame | Letzte Änderung | Log anzeigen | RSS feed
** Introduction:PEAR MDB is a project to merge PEAR DB and Metabase into one DBabstraction layer.You can get info on these at:PEAR DB: http://pear.php.netMetabase: http://phpclasses.upperdesign.com/browse.html/package/20/At these URLs you will also find the licensing information on these twoprojects along with the credits.If you have any questions or suggestions you can contact me (Lukas Smith)at this email address:smith@backendmedia.comCo-Author is Christopher Linn:clinn@backendmedia.comOr even better post a message to these 3 mailinglists (please includeall of these because there are people on each of these mailinglists thatcare about this project and have asked to be included in anydiscussion):pear-dev@lists.php.netmetabase-dev@yahoogroups.comdev@binarycloud.tigris.org** FeaturesMDB provides a common API for all support RDBMS. The main difference to mostother DB abstraction packages is that MDB goes much further to ensureportability. Among other things MDB features:* An OO-style query API* A DSN (data source name) or array format for specifying database servers* Datatype abstraction and on demand datatype conversion* Portable error codes* Sequential and non sequential row fetching as well as bulk fetching* Ordered array and associative array for the fetched rows* Prepare/execute (bind) emulation* Sequence emulation* Replace emulation* Limited Subselect emulation* Row limit support* Transactions support* Large Object support* Index/Unique support* Extension Framework to load advanced functionality on demand* Table information interface* RDBMS management methods (creating, dropping, altering)* RDBMS independent xml based schema definition management* Altering of a DB from a changed xml schema* Reverse engineering of xml schemas from an existing DB (currently only MySQL)* Full integration into the PEAR Framework* Wrappers for the PEAR DB and Metabase APIs* PHPDoc API documentationCurrently supported RDBMS:MySQLPostGreSQLOracle (beta)Frontbase SQL (alpha)QuerysimOther soon to follow.** Getting started:I would first recommend taking a look at MDB_test.php.This should give you a general feel of how to interact with MDB.After that you may want to take a look at the rather large APIat www.backendmedia.com/MDB/docs. There you will also find a documentdescribing the xml schema format and a little tutorial (it wasjust recently ported from Metabase, so it may contain errors).** Current State:The current release can be found at the PEAR webpage:http://pear.php.net/package-info.php?package=MDB----------------------------------- WARNING -----------------------------------MDB is still undergoing active development and therefore its API mightchange slightly until drivers for ODBC and Sybase/MS-SQL have been added. Butsince MDB is heavily based on PEAR DB and Metabase who both have drivers forthese RDBMS this is probably fairly unlikely to happen or have large effects.It is unlikely that BC specific code will be written to maintain BC for onlyrelease prior to this version.Furthermore the manager might see some drastic changes in the future which wouldaffect the manager.php and the get*Definition() methods in the manager_*.php.However this will most likely be extending the functionality and not changingexisting functionality.----------------------------------- WARNING -----------------------------------All but the MySQL driver are still missing the reverse engineering of xml schemas.The core of MDB is very stable since quite sometime, with very few bugs thathad to be fixed or API changes that had to be made. The manager is still in abit of flux as the API is still not final and some methods still need to besplit up into smaller methods to improve readability and flexability. Alsonew features will be added as needed by the MDB_frontend project.The 1.0 of MDB can be considered stable for the RDBMS it currentlysupports. As with any software there is the possiblity of bugs which I amcommited to fix quickly. As explained above there may be changes in the APIthat may break BC until we hit 1.1. The version number 1.0 was just a naturalprogression from the initial version number of 0.9. This 1.0 release is adefinite milestone and the version number reflects this. The next milestonewill be 1.1 to be expected in Fall 2002 (see the Roadmap for details).** Package Content:As a user the only php script you will need to include is MDB.php which willinstall to your PEAR root directory. All other files and their containingclasses will be included via MDB::factory(), MDB::connect(), MDB::loadFile().Currently the supported drivers are mysql and pgsql.File you may include are:peardb_wrapper (PEAR DB Wrapper)metabase_wrapper (Metabase Wrapper)Date (MDB_Date class which helps in converting MDB Timestamps to other formats)Manager (MDB_Manager class which does the XML schema handling)The only exception to this rule is reverse_engineer_xml_schema.php which youhave to call directly from a browser. This very simple script will help youwith handling schema files and create schema files from existing databases. Thisscript requires PEAR::Var_Dump package.The package also contains various files that explain how MDB works. These fileswill install into your docs dir found in the PEAR root dir.Furthermore MDB provides an extensive testing framework that works through abrowser and command line interface. There are several other test that test thetwo wrappers. These files will install into your test dir found in thePEAR root dir.** Documentation:PHPDoc generated documentation can be found at: http://www.backendmedia.com/MDB/docs/The entire "public" API and most of the "private" methods (except for some ofthe lob classes) have been documented with PHPDoc comments. Most of the APIis borrowed from PEAR DB, so you can look there for detailed documentation.Since there are a large number of new methods available thanks to the Metabaseheritage of MDB you will also have to take a look in the Metabase documentation(which can be found at the URL mentioned above, but does require thatyou register with phpclasses). Most of these Metabase functions havebeen renamed. Looking at the metabase_wrapper.php file should help findingthe new method name in MDB.For example ($db being an MDB object):$converted_value = MetabaseGetTimestampFieldValue($database, $value);would now be$converted_value = $db->getTimestampValue($value);If you want to help out with documentation please email me.** Testing:For most of the tests you can set the username/password/hostname in the relevantconfig file. The user will need to have the right to create new databases.test.php/clitest.php/testchoose.php: Is the native testing suite provided byMDB. Please see the README in the tests directory for details.driver_test.php: Is the testing suite provided by Metabase you will needto configure what driver to test and the relevant section in the array found indriver_test_config.php to fit your enviornment.MDB_test.php: Several test calls to MDB's native API.MDB_pear_wrapper_test.php: Several test calls to MDB's PEAR DB Wrapper.MDB_test.php and MDB_pear_wrapper_test.php require PEAR::VAR_Dump package andare configured to use the following settings:username = metapearpassword = funkyhostname = localhost** How to write new Drivers:Skeleton drivers are provided in the docs directory of the MDB package.MDB is mostly based in Metabase. The method naming and formatting ischanged to better match the PEAR CS however. Therefore the best startingpoint is to first take one of the Metabase drivers (metabase_[DRIVER NAME].php)and compare it with a corresponding MDB driver ([DRIVER NAME].php andmanager_[DRIVER NAME].php). This will give a good idea what changes you have tomake to an existing Metabase driver in order to make it MDB compatible.(Note: In order to get the Metabase code you will need to download it fromphpclasses using the URL provided at the top).Alot of methods have been renamed from the original Metabase API. The bestplace to find the name to what a method has been renamed you should lookat the metabase_wrapper.php file.Please also note that some methods have been taken from PEAR DB so for somemissing methods you can check the PEAR DB driver.Another alternative would be to take a MDB driver and hack it to fitthe new RDBMS. I would however recommend working with the existingMetabase driver for that RDBMS when doing those changes. This willsurely be faster and it will ensure that the new driver takes fulladvantage of the MDB framework (which is to large parts based onMetabase).In order to check compliance of the driver with MDB you can use the testingsuite (see the "testing" section above)** HistoryMDB was started after Manuel broad be into the discussion about getting thefeatures of Metabase into PEAR that was going on (again) in December 2001. Hesuggested that I could take on this project. After alot of discussion abouthow when and if etc I started development in February 2002.MDB is based on Metabase but has been reworked severely to better matchthe PEAR DB API and PEAR CS. The approach I have taken so far is to take DB.phpfrom PEAR DB and make it create a Metabase object. I have changed theMetabase structure slightly. The formatting has been reworkedconsiderably to better fit the final structure (MDB standalone with aBC-wrapper for Metabase and PEAR DB), to fit the PEAR CS and to make iteasier for other people to contribute.The metabase_interface.php was been renamed to metabase_wrapper.php andnow only serves as a wrapper to keep BC with Metabase. A wrapper willhave to be created for PEAR DB as well.Basically the result is a Metabase that is really close to the PEAR DBstructure. I have also added any missing methods from PEAR DB. Work onmoving the error handling to PEAR error handling is under way but stillneeds some work.** Credits (never to early for those huh? :-) ):I would especially like to thank Manuel Lemos (Author of Metabase) forgetting me involved in this and generally being around to ask questions.I would also like to thank Tomas Cox and Stig S. Bakken from the PEARprojects for help in undertstanding PEAR, solving problems and trustingme enough. Paul Cooper for the work on the pgsql driver. Furthermore Iwould like to thank Alex Black for being so enthusiastic about thisproject and offering binarycloud as a test bed for this project.Christian Dickmann for being the first to put MDB to some real use,making MDB use PEAR Error and working on the XML schema manager.Finally Peter Bowyer for starting the discussion that made people pickup this project again after the first versions of what was then called"metapear" have been ideling without much feedback. I guess I shouldalso thank BackendMedia (my company :-) ) for providing the necessary meansto develop this on company time (actually for the most part my entirelife is company time ... so it goes)