本文整理汇总了PHP中dibi::date方法的典型用法代码示例。如果您正苦于以下问题:PHP dibi::date方法的具体用法?PHP dibi::date怎么用?PHP dibi::date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dibi
的用法示例。
在下文中一共展示了dibi::date方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date_default_timezone_set
<h1>IDibiVariable example</h1>
<?php
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
// CHANGE TO REAL PARAMETERS!
dibi::connect(array('driver' => 'sqlite', 'database' => 'sample.sdb', 'formatDate' => "'Y-m-d'", 'formatDateTime' => "'Y-m-d H-i-s'"));
// generate and dump SQL
dibi::test("\nINSERT INTO [mytable]", array('id' => 123, 'date' => dibi::date('12.3.2007'), 'stamp' => dibi::dateTime('23.1.2007 10:23')));
// -> INSERT INTO [mytable] ([id], [date], [stamp]) VALUES (123, '2007-03-12', '2007-01-23 10-23-00')
示例2: date_default_timezone_set
<h1>Query Language Basic Examples | dibi</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'));
// SELECT
$ipMask = '192.168.%';
$timestamp = mktime(0, 0, 0, 10, 13, 1997);
dibi::test('
SELECT COUNT(*) as [count]
FROM [comments]
WHERE [ip] LIKE %s', $ipMask, '
AND [date] > ', dibi::date($timestamp));
// -> SELECT COUNT(*) as [count] FROM [comments] WHERE [ip] LIKE '192.168.%' AND [date] > 876693600
// dibi detects INSERT or REPLACE command
dibi::test('
REPLACE INTO products', array('title' => 'Super product', 'price' => 318, 'active' => TRUE));
// -> REPLACE INTO products ([title], [price], [active]) VALUES ('Super product', 318, 1)
// multiple INSERT command
$array = array('title' => 'Super Product', 'price' => 12, 'brand' => NULL, 'created' => new DateTime());
dibi::test("INSERT INTO products", $array, $array, $array);
// -> INSERT INTO products ([title], [price], [brand], [created]) VALUES ('Super Product', ...) , (...) , (...)
// dibi detects UPDATE command
dibi::test("\n\tUPDATE colors SET", array('color' => 'blue', 'order' => 12), "\n\tWHERE id=%i", 123);
// -> UPDATE colors SET [color]='blue', [order]=12 WHERE id=123
// modifier applied to array
$array = array(1, 2, 3);
dibi::test("\n\tSELECT *\n\tFROM people\n\tWHERE id IN (%i)", $array);