Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
** Introduction:
2
 
3
PEAR MDB2 is a project to merge PEAR DB and Metabase into one DB
4
abstraction layer.
5
 
6
You can get info on these at:
7
  PEAR DB: http://pear.php.net
8
  Metabase: http://phpclasses.upperdesign.com/browse.html/package/20/
9
 
10
At these URLs you will also find the licensing information on these two
11
projects along with the credits.
12
 
13
Actually MDB2 is the second major version of MDB.
14
The main differences between the new MDB2 and the old MDB version is
15
that the API has been drastically refactored to clean up the API
16
and improve performance.
17
 
18
If you have any questions or suggestions you can contact me (Lukas Smith)
19
at this email address:
20
  smith@backendmedia.com
21
Co-Author is Christopher Linn:
22
  clinn@backendmedia.com
23
 
24
Or even better post a message to pear-dev@lists.php.net mailinglist for
25
development related questions of the MDB2 package itself. For questions
26
using MDB2 pelase direct your questions at pear-general@lists.php.net.
27
 
28
** Features
29
 
30
MDB2 provides a common API for all support RDBMS. The main difference to most
31
other DB abstraction packages is that MDB2 goes much further to ensure
32
portability. Among other things MDB2 features:
33
* An OO-style query API
34
* A DSN (data source name) or array format for specifying database servers
35
* Datatype abstraction and on demand datatype conversion
36
* Portable error codes
37
* Sequential and non sequential row fetching as well as bulk fetching
38
* Ordered array and associative array for the fetched rows
39
* Buffered and Unbuffered fetching
40
* Prepare/execute (bind) emulation
41
* Sequence emulation
42
* Replace emulation
43
* Limited Subselect emulation
44
* Row limit support
45
* Transactions support
46
* Large Object support
47
* Index/Unique support
48
* Extension Framework to load advanced functionality on demand
49
* Table information interface
50
* RDBMS management methods (creating, dropping, altering)
51
* RDBMS independent xml based schema definition management
52
* Altering of a DB from a changed xml schema
53
* Reverse engineering of xml schemas from an existing DB (currently MySQL and PgSQl)
54
* Full integration into the PEAR Framework
55
* PHPDoc API documentation
56
 
57
** Getting started:
58
 
59
I would first recommend taking a look at example.php.
60
This should give you a general feel of how to interact with MDB2.
61
 
62
After that you may want to take a look at the rather large API
63
at www.backendmedia.com/MDB2/docs. There you will also find a document
64
describing the xml schema format and a little tutorial (it was
65
just recently ported from Metabase, so it may contain errors).
66
 
67
** Current State:
68
 
69
The current release can be found at the PEAR webpage:
70
  http://pear.php.net/package-info.php?package=MDB2
71
 
72
** Package Content:
73
 
74
As a user the only php script you will need to include is MDB2.php which will
75
install to your PEAR root directory. All other files and their containing
76
classes will be included via MDB2::factory(), MDB2::connect(), MDB2::singleton().
77
 
78
These will load additional classes. Most classes are loaded on demand.
79
 
80
Furthermore MDB2 provides an extensive testing framework that works through a
81
browser and command line interface. There are several other test that test the
82
two wrappers. These files will install into your test dir found in the
83
PEAR root dir.
84
 
85
** Documentation:
86
 
87
You can find the still incomplete documentation for MDB2 here:
88
http://pear.php.net/manual/en/package.database.mdb2.php
89
 
90
PHPDoc generated documentation can be found at:
91
http://www.backendmedia.com/MDB2/docs/
92
 
93
The entire "public" API and most of the "private" methods (except for some of
94
the lob classes) have been documented with PHPDoc comments. Most of the API
95
is borrowed from extPDO, so you can look there for detailed documentation.
96
Since there are a large number of new methods available thanks to the Metabase
97
heritage of MDB2 you will also have to take a look in the Metabase documentation
98
(which can be found at the URL mentioned above, but does require that
99
you register with phpclasses). Most of these Metabase functions have
100
been renamed and changed considerably. The main things left are the datatypes
101
and the manager module.
102
 
103
For example ($db being an MDB2 object):
104
  $converted_value = MetabaseGetTimestampFieldValue($database, $value);
105
would now be
106
  $converted_value = $db->quote($value, 'timestamp');
107
 
108
If you want to help out with documentation please email me.
109
 
110
** Testing:
111
 
112
For most of the tests you can set the username/password/hostname in the relevant
113
config file. The user will need to have the right to create new databases.
114
 
115
test.php/clitest.php/testchoose.php: Is the native testing suite provided by
116
MDB2. Please see the README in the tests directory for details.
117
 
118
example.php: Several test calls to MDB2's native API. It require PEAR::VAR_Dump
119
package and are configured to use the following settings:
120
username = metapear
121
password = funky
122
hostname = localhost
123
 
124
** How to write new Drivers:
125
 
126
Skeleton drivers are provided in the docs directory of the MDB2 package.
127
 
128
The best course of action would be to take a MDB2 driver and hack it to fit
129
the new RDBMS. This will surely be faster and it will ensure that the new
130
driver takes full advantage of the MDB2 framework. I would however recommend
131
working with the existing Metabase driver for inspiration that RDBMS when
132
doing those changes.
133
 
134
In order to check compliance of the driver with MDB2 you can use the testing
135
suite (see the "testing" section above)
136
 
137
** History
138
 
139
MDB was started after Manuel broad be into the discussion about getting the
140
features of Metabase into PEAR that was going on (again) in December 2001. He
141
suggested that I could take on this project. After alot of discussion about
142
how when and if etc I started development in February 2002.
143
 
144
MDB is based on Metabase but has been reworked severely to better match
145
the PEAR DB API and PEAR CS. The approach I have taken so far is to take DB.php
146
from PEAR DB and make it create a Metabase object. I have changed the
147
Metabase structure slightly. The formatting has been reworked
148
considerably to better fit the final structure (MDB standalone with a
149
BC-wrapper for Metabase and PEAR DB), to fit the PEAR CS and to make it
150
easier for other people to contribute.
151
 
152
The metabase_interface.php was been renamed to metabase_wrapper.php and
153
now only serves as a wrapper to keep BC with Metabase. A wrapper will
154
have to be created for PEAR DB as well.
155
 
156
Basically the result is a Metabase that is really close to the PEAR DB
157
structure. I have also added any missing methods from PEAR DB. Work on
158
moving the error handling to PEAR error handling is under way but still
159
needs some work.
160
 
161
In MDB2 the API was heavily refactored to be even more streamlined. Redundant
162
features have been removed. Some features where moved out of the core into
163
separate loadable modules. Instead of resources resultsets are now wrapped
164
into objects similar to PEAR DB.
165
 
166
** Credits (never to early for those huh? :-)  ):
167
 
168
I would especially like to thank Manuel Lemos (Author of Metabase) for
169
getting me involved in this and generally being around to ask questions.
170
I would also like to thank Tomas Cox and Stig S. Bakken from the PEAR
171
projects for help in undertstanding PEAR, solving problems and trusting
172
me enough. Paul Cooper for the work on the pgsql driver. Furthermore I
173
would like to thank Alex Black for being so enthusiastic about this
174
project and offering binarycloud as a test bed for this project.
175
Christian Dickmann for being the first to put MDB to some real use,
176
making MDB use PEAR Error and working on the XML schema manager.
177
 
178
Finally Peter Bowyer for starting the discussion that made people pick
179
up this project again after the first versions of what was then called
180
"metapear" have been ideling without much feedback. I guess I should
181
also thank BackendMedia (my company :-)  ) for providing the necessary means
182
to develop this on company time (actually for the most part my entire
183
life is company time ... so it goes)