2006-06-04 23:06:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once '../dibi/dibi.php';
|
|
|
|
|
2006-11-13 06:32:16 +00:00
|
|
|
|
|
|
|
try {
|
2007-02-02 03:51:43 +00:00
|
|
|
|
|
|
|
// connects to MySQL using DSN
|
2006-11-13 06:32:16 +00:00
|
|
|
dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=utf8');
|
|
|
|
|
2007-02-02 03:51:43 +00:00
|
|
|
|
|
|
|
// connects to MySQL / MySQLi
|
|
|
|
dibi::connect(array(
|
|
|
|
'driver' => 'mysql', // or 'mysqli'
|
|
|
|
'host' => 'localhost',
|
|
|
|
'username' => 'root',
|
|
|
|
'password' => 'xxx',
|
|
|
|
'database' => 'dibi',
|
|
|
|
'charset' => 'utf8',
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
// connects to ODBC
|
|
|
|
dibi::connect(array(
|
|
|
|
'driver' => 'odbc',
|
|
|
|
'username' => 'root',
|
|
|
|
'password' => '***',
|
|
|
|
'database' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\Database.mdb',
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
// connects to SQlite
|
|
|
|
dibi::connect(array(
|
|
|
|
'driver' => 'sqlite',
|
|
|
|
'database' => 'mydb.sdb',
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
// connects to PostgreSql
|
|
|
|
dibi::connect(array(
|
|
|
|
'driver' => 'postgre',
|
|
|
|
'string' => 'host=localhost port=5432 dbname=mary',
|
|
|
|
'persistent' => TRUE,
|
|
|
|
));
|
|
|
|
|
|
|
|
|
2006-11-13 06:32:16 +00:00
|
|
|
} catch (DibiException $e) {
|
2006-06-04 23:06:33 +00:00
|
|
|
|
2007-02-02 03:51:43 +00:00
|
|
|
echo "DibiException: <pre>", $e;
|
2006-06-07 15:50:32 +00:00
|
|
|
|
|
|
|
}
|