1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-22 18:02:25 +01:00
php-dibi/examples/connect.php

52 lines
1.1 KiB
PHP
Raw Normal View History

2006-06-04 23:06:33 +00:00
<?php
require_once '../dibi/dibi.php';
2006-09-13 12:02:38 +00:00
// connects using DSN
2006-07-19 01:40:29 +00:00
$state = dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=utf8');
2006-06-04 23:06:33 +00:00
2006-06-07 15:50:32 +00:00
// connects to mysql
2006-06-04 23:06:33 +00:00
$state = dibi::connect(array(
'driver' => 'mysql',
'host' => 'localhost',
'username' => 'root',
2006-06-07 15:50:32 +00:00
'password' => 'xxx', // change to real password!
2006-06-04 23:06:33 +00:00
'database' => 'test',
'charset' => 'utf8',
2006-06-07 15:50:32 +00:00
));
2006-06-04 23:06:33 +00:00
2006-06-07 15:50:32 +00:00
/* connects to ODBC
2006-06-04 23:06:33 +00:00
dibi::connect(array(
'driver' => 'odbc',
'username' => 'root',
'password' => '***',
'database' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\Database.mdb',
2006-06-07 15:50:32 +00:00
));
*/
2006-09-13 12:02:38 +00:00
/* 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-06-07 15:50:32 +00:00
// check status
if (!dibi::isConnected()) {
echo 'dibi::isConnected(): Not connected';
echo "<br>\n";
2006-08-25 15:17:40 +00:00
} else {
echo 'Connected';
2006-06-07 15:50:32 +00:00
}
2006-06-04 23:06:33 +00:00
?>