2010-08-03 12:28:07 +02:00
|
|
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
|
|
|
|
2013-12-19 04:37:53 +01: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
|
|
|
|
|
2014-06-27 11:17:22 +02:00
|
|
|
if (@!include __DIR__ . '/../vendor/autoload.php') {
|
|
|
|
die('Install dependencies using `composer install --dev`');
|
|
|
|
}
|
2013-12-19 04:37:53 +01:00
|
|
|
|
|
|
|
Tracy\Debugger::enable();
|
2008-07-17 03:51:29 +00:00
|
|
|
|
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(
|
2015-06-19 03:11:36 +02:00
|
|
|
'driver' => 'sqlite3',
|
2012-10-18 23:00:12 +02:00
|
|
|
'database' => 'data/sample.s3db',
|
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-18 21:08:34 +01:00
|
|
|
->setType('added', Dibi::DATETIME)
|
|
|
|
->setFormat(dibi::DATETIME, 'Y-m-d H:i:s');
|
|
|
|
|
2008-07-17 03:51:29 +00:00
|
|
|
|
2015-06-19 03:11:36 +02:00
|
|
|
Tracy\Dumper::dump($res->fetch());
|
2010-08-03 11:48:51 +02:00
|
|
|
// outputs:
|
2013-06-23 01:57:48 +02:00
|
|
|
// DibiRow(3) {
|
|
|
|
// customer_id => 1
|
|
|
|
// name => "Dave Lister" (11)
|
|
|
|
// added => "2007-03-11 17:20:03" (19)
|
2010-08-03 11:48:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
// using auto-detection (works well with MySQL or other strictly typed databases)
|
|
|
|
$res = dibi::query('SELECT * FROM [customers]');
|
|
|
|
|
2015-06-19 03:11:36 +02:00
|
|
|
Tracy\Dumper::dump($res->fetch());
|
2008-10-28 02:06:55 +00:00
|
|
|
// outputs:
|
2013-06-23 01:57:48 +02:00
|
|
|
// DibiRow(3) {
|
|
|
|
// customer_id => 1
|
|
|
|
// name => "Dave Lister" (11)
|
|
|
|
// added => "2007-03-11 17:20:03" (19)
|