mirror of
https://github.com/dg/dibi.git
synced 2025-08-29 16:59:49 +02:00
* modified DibiException (getDbError, ...)
* fix dibi::dumpResult()
This commit is contained in:
@@ -4,55 +4,53 @@ require_once '../dibi/dibi.php';
|
||||
|
||||
|
||||
try {
|
||||
// connects using DSN
|
||||
|
||||
// connects to MySQL using DSN
|
||||
dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=utf8');
|
||||
|
||||
|
||||
// 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,
|
||||
));
|
||||
|
||||
|
||||
} catch (DibiException $e) {
|
||||
echo "DibiException: " . $e->getMessage();
|
||||
die();
|
||||
|
||||
echo "DibiException: <pre>", $e;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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';
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user