mirror of
https://github.com/dg/dibi.git
synced 2025-08-10 08:04:32 +02:00
added DibiDriver::disconnect()
This commit is contained in:
@@ -30,10 +30,10 @@ try {
|
||||
|
||||
|
||||
|
||||
// connects to MySQL / MySQLi
|
||||
// connects to MySQLi using array
|
||||
try {
|
||||
dibi::connect(array(
|
||||
'driver' => 'mysql', // or 'mysqli'
|
||||
'driver' => 'mysqli',
|
||||
'host' => 'localhost',
|
||||
'username' => 'root',
|
||||
'password' => 'xxx',
|
||||
@@ -109,3 +109,19 @@ try {
|
||||
} catch (DibiException $e) {
|
||||
echo '<pre>', $e, '</pre>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// connects to Oracle
|
||||
try {
|
||||
dibi::connect(array(
|
||||
'driver' => 'oracle',
|
||||
'username' => 'root',
|
||||
'password' => 'xxx',
|
||||
'database' => 'db',
|
||||
));
|
||||
echo '<p>Connected to Oracle</p>';
|
||||
|
||||
} catch (DibiException $e) {
|
||||
echo '<pre>', $e, '</pre>';
|
||||
}
|
||||
|
27
examples/extension.method.php
Normal file
27
examples/extension.method.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<h1>dibi extension method example</h1>
|
||||
<pre>
|
||||
<?php
|
||||
|
||||
require_once '../dibi/dibi.php';
|
||||
|
||||
|
||||
dibi::connect(array(
|
||||
'driver' => 'sqlite',
|
||||
'database' => 'sample.sdb',
|
||||
));
|
||||
|
||||
|
||||
|
||||
// using the "prototype" to add custom method to class DibiResult
|
||||
function DibiResult_prototype_fetchShuffle(DibiResult $obj)
|
||||
{
|
||||
$all = $obj->fetchAll();
|
||||
shuffle($all);
|
||||
return $all;
|
||||
}
|
||||
|
||||
|
||||
// fetch complete result set shuffled
|
||||
$res = dibi::query('SELECT * FROM [customers]');
|
||||
$all = $res->fetchShuffle();
|
||||
print_r($all);
|
Reference in New Issue
Block a user