Introduction (Previous) (Next) Get Database Definition

View this page in Last updated: Sun, 28 Sep 2008
English | French | German | Hungarian | Japanese | Spanish | Plain HTML

Installation et Exemple d'utilisation

Installation et Exemple d'utilisation --  Installation et exemple d'utilisation de MDB2_Schema

Installation

Vous devez d'abord avoir MDB2 installé:

$ pear install --alldeps MDB2

Vous devez aussi installer un driver pour chaque type de base de donnée que vous utilisez. Pour MySQL ca sera:

$ 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 est un paquet séparé, et peut aussi être installé avec l'installeur de PEAR :

$ pear install --alldeps MDB2_Schema-beta

Maintenant vous devriez être prêt :)

Exemple d'utilisation

Pour créer une instance de la classe MDB2_Schema vous pouvez utiliser factory(), qui accepte un $dsn ou un tableau. La méthode factory accepte aussi un objet MDB2. L'exemple qui suit utilise un $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();
?>

Introduction (Previous) (Next) Get Database Definition

Download Documentation Last updated: Sun, 28 Sep 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.