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
|
|
|
|
|
2018-03-23 11:57:59 +01:00
|
|
|
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',
|
2012-10-18 23:00:12 +02:00
|
|
|
'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')
|