1
0
mirror of https://github.com/dg/dibi.git synced 2025-10-22 18:26:13 +02:00
Files
php-dibi/examples/metatypes.php
2010-08-03 13:41:06 +02:00

33 lines
690 B
PHP

<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
<h1>dibi metatypes example</h1>
<?php
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array(
'driver' => 'sqlite',
'database' => 'data/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"
// }