1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-23 18:33:45 +01:00
php-dibi/examples/using-datetime.php

35 lines
753 B
PHP
Raw Normal View History

2017-07-21 21:34:37 +02:00
<?php
declare(strict_types=1);
?>
2010-08-03 13:54:05 +02:00
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
<h1>Using DateTime | dibi</h1>
<?php
if (@!include __DIR__ . '/../vendor/autoload.php') {
die('Install packages using `composer install`');
}
2010-08-03 13:54:05 +02:00
date_default_timezone_set('Europe/Prague');
// CHANGE TO REAL PARAMETERS!
2018-04-17 10:03:43 +02:00
$dibi = new Dibi\Connection([
2015-06-19 03:11:36 +02:00
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
2010-08-03 13:54:05 +02:00
'formatDate' => "'Y-m-d'",
'formatDateTime' => "'Y-m-d H-i-s'",
2015-10-06 01:39:01 +02:00
]);
2010-08-03 13:54:05 +02:00
// generate and dump SQL
2018-04-17 10:03:43 +02:00
$dibi->test('
2015-10-06 01:39:01 +02:00
INSERT INTO [mytable]', [
2015-06-19 03:11:36 +02:00
'id' => 123,
'date' => new DateTime('12.3.2007'),
2010-08-03 13:54:05 +02:00
'stamp' => new DateTime('23.1.2007 10:23'),
2015-10-06 01:39:01 +02:00
]
2010-08-03 13:54:05 +02:00
);
// -> INSERT INTO [mytable] ([id], [date], [stamp]) VALUES (123, '2007-03-12', '2007-01-23 10-23-00')