mirror of
https://github.com/dg/dibi.git
synced 2025-01-17 22:28:50 +01:00
48 lines
1013 B
PHP
48 lines
1013 B
PHP
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
|
|
|
<h1>Result Set Data Types | dibi</h1>
|
|
|
|
<?php
|
|
|
|
require_once 'Nette/Debugger.php';
|
|
require_once '../dibi/dibi.php';
|
|
|
|
ndebug();
|
|
date_default_timezone_set('Europe/Prague');
|
|
|
|
|
|
dibi::connect(array(
|
|
'driver' => 'sqlite',
|
|
'database' => 'data/sample.sdb',
|
|
));
|
|
|
|
|
|
// using manual hints
|
|
$res = dibi::query('SELECT * FROM [customers]');
|
|
|
|
$res->setType('customer_id', Dibi::INTEGER)
|
|
->setType('added', Dibi::DATETIME)
|
|
->setFormat(dibi::DATETIME, 'Y-m-d H:i:s');
|
|
|
|
|
|
dump( $res->fetch() );
|
|
// outputs:
|
|
// object(DibiRow)#3 (3) {
|
|
// customer_id => int(1)
|
|
// name => string(11) "Dave Lister"
|
|
// added => object(DateTime53) {}
|
|
// }
|
|
|
|
|
|
|
|
// using auto-detection (works well with MySQL or other strictly typed databases)
|
|
$res = dibi::query('SELECT * FROM [customers]');
|
|
|
|
dump( $res->fetch() );
|
|
// outputs:
|
|
// object(DibiRow)#3 (3) {
|
|
// customer_id => int(1)
|
|
// name => string(11) "Dave Lister"
|
|
// added => string(15) "17:20 11.3.2007"
|
|
// }
|