1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-24 02:43:09 +01:00
php-dibi/examples/metatypes.php
2009-04-16 02:15:20 +00:00

31 lines
628 B
PHP

<h1>dibi metatypes example</h1>
<pre>
<?php
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array(
'driver' => 'sqlite',
'database' => 'sample.sdb',
));
$res = dibi::query('SELECT * FROM [customers]');
// auto-converts this column to integer
$res->setType('customer_id', Dibi::INTEGER);
$res->setType('added', Dibi::DATETIME, 'H:i j.n.Y');
$row = $res->fetch();
Debug::dump($row);
// outputs:
// object(DibiRow)#3 (3) {
// customer_id => int(1)
// name => string(11) "Dave Lister"
// added => string(15) "17:20 11.3.2007"
// }