1
0
mirror of https://github.com/dg/dibi.git synced 2025-10-22 10:16:02 +02:00
Files
php-dibi/examples/connect.php
2006-11-13 06:32:16 +00:00

58 lines
1.2 KiB
PHP

<?php
require_once '../dibi/dibi.php';
try {
// connects using DSN
dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=utf8');
} catch (DibiException $e) {
echo "DibiException: " . $e->getMessage();
die();
}
// connects to mysql
dibi::connect(array(
'driver' => 'mysql',
'host' => 'localhost',
'username' => 'root',
'password' => 'xxx', // change to real password!
'database' => 'test',
'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,
));
*/
// check status
if (!dibi::isConnected()) {
echo 'dibi::isConnected(): Not connected';
} else {
echo 'Connected';
}
?>