1
0
mirror of https://github.com/dg/dibi.git synced 2025-07-10 17:16:25 +02:00
Files
php-dibi/examples/result-set-data-types.php
David Grudl ce459f440a improved coding style
# Conflicts:
#	dibi/bridges/Tracy/Panel.php
#	dibi/drivers/DibiPdoDriver.php
#	dibi/drivers/DibiPostgreDriver.php
#	tests/dibi/DataSource.phpt
#	tests/dibi/DibiConnection.connect.phpt
#	tests/dibi/DibiConnection.transactions.phpt
#	tests/dibi/DibiFluent.cloning.phpt
#	tests/dibi/DibiFluent.insert.phpt
#	tests/dibi/DibiFluent.select.phpt
#	tests/dibi/DibiFluent.update.phpt
#	tests/dibi/DibiTranslator.conditions.phpt
#	tests/dibi/DibiTranslator.phpt
#	tests/dibi/PdoMssql.limits.phpt
#	tests/dibi/Postgre.like.phpt
2015-10-09 12:01:02 +02:00

47 lines
1.0 KiB
PHP

<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
<h1>Result Set Data Types | dibi</h1>
<?php
if (@!include __DIR__ . '/../vendor/autoload.php') {
die('Install dependencies using `composer install --dev`');
}
Tracy\Debugger::enable();
date_default_timezone_set('Europe/Prague');
dibi::connect(array(
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
// using manual hints
$res = dibi::query('SELECT * FROM [customers]');
$res->setType('customer_id', Dibi::INTEGER)
->setType('added', Dibi::DATETIME)
->setFormat(dibi::DATETIME, 'Y-m-d H:i:s');
Tracy\Dumper::dump($res->fetch());
// outputs:
// DibiRow(3) {
// customer_id => 1
// name => "Dave Lister" (11)
// added => "2007-03-11 17:20:03" (19)
// using auto-detection (works well with MySQL or other strictly typed databases)
$res = dibi::query('SELECT * FROM [customers]');
Tracy\Dumper::dump($res->fetch());
// outputs:
// DibiRow(3) {
// customer_id => 1
// name => "Dave Lister" (11)
// added => "2007-03-11 17:20:03" (19)