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>Result Set Data Types | 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';
|
|
|
|
|
2009-04-16 02:15:20 +00:00
|
|
|
date_default_timezone_set('Europe/Prague');
|
|
|
|
|
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
|
|
|
));
|
|
|
|
|
|
|
|
|
2010-08-03 11:48:51 +02:00
|
|
|
// using manual hints
|
2008-07-17 03:51:29 +00:00
|
|
|
$res = dibi::query('SELECT * FROM [customers]');
|
|
|
|
|
2010-08-03 11:48:51 +02:00
|
|
|
$res->setType('customer_id', Dibi::INTEGER)
|
2012-01-11 23:01:10 +01:00
|
|
|
->setType('added', Dibi::DATETIME);
|
2008-07-17 03:51:29 +00:00
|
|
|
|
2011-07-01 08:06:36 +02:00
|
|
|
Debugger::dump( $res->fetch() );
|
2010-08-03 11:48:51 +02:00
|
|
|
// 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]');
|
|
|
|
|
2011-07-01 08:06:36 +02:00
|
|
|
Debugger::dump( $res->fetch() );
|
2008-10-28 02:06:55 +00:00
|
|
|
// outputs:
|
|
|
|
// object(DibiRow)#3 (3) {
|
|
|
|
// customer_id => int(1)
|
|
|
|
// name => string(11) "Dave Lister"
|
|
|
|
// added => string(15) "17:20 11.3.2007"
|
|
|
|
// }
|