Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17199 программистов и 1835 роботов. Сейчас ищут 1565 программистов ...
Installation and Usage Example
Вернуться к: MDB2_Schema
Installation and Usage Example
Installation and Usage Example – Installation and example for the usage of MDB2_Schema
First you need MDB2 installed:
$ pear install --alldeps MDB2
You should install a driver for each database you are working with. For MySQL it would be:
$ pear install MDB2_Driver_Mysql
For some hints refers to MDB2 documentation or try in a UNIX-like system:
$ pear remote-list | grep MDB2
MDB2_Schema is a separate package, and can also be installed using the PEAR installer:
$ pear install --alldeps MDB2_Schema-beta
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();
?>
Вернуться к: MDB2_Schema