Exemplo n.º 1
0
 /**
  * Required by the Countable interface.
  * @return int
  */
 public function count()
 {
     return $this->result->getRowCount();
 }
Exemplo n.º 2
0
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">

<h1>Using Extension Methods | dibi</h1>

<?php 
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
    die('Install dependencies using `composer install --dev`');
}
Tracy\Debugger::enable();
dibi::connect(array('driver' => 'sqlite3', 'database' => 'data/sample.s3db'));
// using the "prototype" to add custom method to class DibiResult
DibiResult::extensionMethod('fetchShuffle', function (DibiResult $obj) {
    $all = $obj->fetchAll();
    shuffle($all);
    return $all;
});
// fetch complete result set shuffled
$res = dibi::query('SELECT * FROM [customers]');
$all = $res->fetchShuffle();
Tracy\Dumper::dump($all);
Exemplo n.º 3
0
function DibiResult_prototype_fetchShuffle(DibiResult $obj)
{
    $all = $obj->fetchAll();
    shuffle($all);
    return $all;
}
 /**
  * Result set factory.
  * @param  IDibiResultDriver
  * @return DibiResult
  */
 public function createResultSet(IDibiResultDriver $resultDriver)
 {
     $res = new DibiResult($resultDriver);
     return $res->setFormat(dibi::DATE, $this->config['result']['formatDate'])->setFormat(dibi::DATETIME, $this->config['result']['formatDateTime']);
 }
Exemplo n.º 5
0
 /**
  * Moves forward to next element.
  * @return void
  */
 public function next()
 {
     //$this->result->seek($this->offset + $this->pointer + 1);
     $this->row = $this->result->fetch();
     $this->pointer++;
 }
Exemplo n.º 6
0
function DibiResult_prototype_fetchArray(DibiResult $obj, $key)
{
    return array_keys($obj->fetchAssoc($key));
}
Exemplo n.º 7
0
 public final function fetch()
 {
     return $this->result->fetch();
 }