Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
require_once 'MDB2/Schema.php';
3
 
4
$dsn = array(
5
    'phptype'  => 'mysql',
6
    'username' => 'username',
7
    'password' => 'password',
8
    'hostspec' => 'host',
9
);
10
$db_options = array();
11
 
12
 
13
$file = dirname(__FILE__).DIRECTORY_SEPARATOR.'driver_test.schema.xml';
14
$variables = array(
15
    'name'   => 'driver_test',
16
    'create' => true,
17
);
18
 
19
$options = array(
20
    'log_line_break'   => '<br />',
21
    'idxname_format'   => '%s',
22
    'debug'            => true,
23
    'quote_identifier' => true,
24
    'force_defaults'   => false,
25
    'portability'      => false
26
);
27
$options = array_merge($options, $db_options);
28
 
29
$schema =& MDB2_Schema::factory($dsn, $options);
30
if (PEAR::isError($schema)) {
31
    echo $schema->getMessage() . ' ' . $schema->getUserInfo();
32
    exit;
33
}
34
 
35
$definition = $schema->parseDatabaseDefinitionFile($file, $variables, true, true);
36
if (PEAR::isError($definition)) {
37
    echo $definition->getMessage() . ' - ' . $definition->getUserInfo();
38
} else {
39
    $operation = $schema->createDatabase($definition);
40
    if (PEAR::isError($operation)) {
41
        echo $operation->getMessage() . ' ' . $operation->getUserInfo();
42
    }
43
}
44
?>
45
DONE!