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

28 lines
498 B
PHP
Raw Normal View History

2006-06-04 23:06:33 +00:00
<pre>
<?php
require_once '../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite',
'database' => 'sample.sdb',
2006-06-04 23:06:33 +00:00
));
$res = dibi::query('SELECT * FROM [customers]');
if (!$res) die('SQL error');
2006-06-07 15:50:32 +00:00
2006-06-04 23:06:33 +00:00
// auto-convert this field to integer
$res->setType('customer_id', Dibi::FIELD_INTEGER);
2007-06-25 17:02:12 +00:00
$row = $res->fetch();
var_dump($row);
2006-06-04 23:06:33 +00:00
// auto-detect all types
// WARNING: THIS WILL NOT WORK WITH SQLITE
2006-06-04 23:06:33 +00:00
$res->setType(TRUE);
2007-06-25 17:02:12 +00:00
$row = $res->fetch();
var_dump($row);