1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-24 10:53:17 +01:00
php-dibi/examples/metatypes.php

31 lines
628 B
PHP
Raw Normal View History

2008-07-17 03:51:29 +00:00
<h1>dibi metatypes example</h1>
<pre>
<?php
require_once 'Nette/Debug.php';
2008-07-17 03:51:29 +00:00
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
2008-07-17 03:51:29 +00:00
dibi::connect(array(
'driver' => 'sqlite',
'database' => 'sample.sdb',
));
$res = dibi::query('SELECT * FROM [customers]');
2008-10-28 02:06:55 +00:00
// auto-converts this column to integer
$res->setType('customer_id', Dibi::INTEGER);
$res->setType('added', Dibi::DATETIME, 'H:i j.n.Y');
2008-07-17 03:51:29 +00:00
$row = $res->fetch();
Debug::dump($row);
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"
// }