2010-08-03 12:28:07 +02:00
|
|
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
|
|
|
|
2010-08-03 11:48:51 +02:00
|
|
|
<h1>Using Extension Methods | dibi</h1>
|
2010-08-03 12:28:07 +02:00
|
|
|
|
2008-07-17 03:51:29 +00:00
|
|
|
<?php
|
|
|
|
|
2011-07-01 08:06:36 +02:00
|
|
|
require_once 'Nette/Debugger.php';
|
2008-07-17 03:51:29 +00:00
|
|
|
require_once '../dibi/dibi.php';
|
|
|
|
|
2012-02-03 13:48:00 +01:00
|
|
|
ndebug();
|
2008-07-17 03:51:29 +00:00
|
|
|
|
|
|
|
dibi::connect(array(
|
|
|
|
'driver' => 'sqlite',
|
2010-08-03 12:11:14 +02:00
|
|
|
'database' => 'data/sample.sdb',
|
2008-07-17 03:51:29 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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();
|
2012-02-03 13:48:00 +01:00
|
|
|
dump($all);
|