Installation and Usage Example
Installation
First you need MDB2 installed:
You should install a driver for each database you are working with. For MySQL it would be:
For some hints refers to MDB2 documentation or try in a UNIX-like system:
MDB2_Schema is a separate package, and can also be installed using the PEAR installer:
now you should be ready :)
Usage Example
To create an instance of the MDB2_Schema class you can use the
factory()
, which accepts a
$dsn
or an array. The factory method also accepts an
existing MDB2 object. In the example below, we will just use a
$dsn
.
<?php
require_once 'MDB2/Schema.php';
$options = array(
'log_line_break' => '<br>',
'idxname_format' => '%s',
'debug' => true,
'quote_identifier' => true,
'force_defaults' => false,
'portability' => false
);
$dsn = 'mysql://root:@localhost/MDB2Example';
$schema =& MDB2_Schema::factory($dsn, $options);
if (PEAR::isError($schema)) {
$error = $schema->getMessage();
}
if (isset($error)) {
var_dump($error);
}
$schema->disconnect();
?>