commit | author | age
|
1cded8
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/include/rcube_sqlite.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
|
8 |
| Copyright (C) 2005, RoundCube Dev. - Switzerland | |
|
9 |
| Licensed under the GNU GPL | |
|
10 |
| | |
|
11 |
| PURPOSE: | |
|
12 |
| Provide callback functions for sqlite that will emulate | |
|
13 |
| sone MySQL functions | |
|
14 |
| | |
|
15 |
+-----------------------------------------------------------------------+ |
|
16 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
17 |
+-----------------------------------------------------------------------+ |
|
18 |
|
|
19 |
$Id$ |
|
20 |
|
|
21 |
*/ |
|
22 |
|
|
23 |
|
|
24 |
function rcube_sqlite_from_unixtime($timestamp) |
|
25 |
{ |
|
26 |
$timestamp = trim($timestamp); |
|
27 |
if (!preg_match("/^[0-9]+$/is", $timestamp)) |
|
28 |
$ret = strtotime($timestamp); |
|
29 |
else |
|
30 |
$ret = $timestamp; |
|
31 |
|
|
32 |
$ret = date("Y-m-d H:i:s", $ret); |
|
33 |
rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret"); |
|
34 |
return $ret; |
|
35 |
} |
|
36 |
|
|
37 |
|
|
38 |
function rcube_sqlite_unix_timestamp($timestamp="") |
|
39 |
{ |
|
40 |
$timestamp = trim($timestamp); |
|
41 |
if (!$timestamp) |
|
42 |
$ret = time(); |
|
43 |
else if (!preg_match("/^[0-9]+$/is", $timestamp)) |
|
44 |
$ret = strtotime($timestamp); |
|
45 |
else |
|
46 |
$ret = $timestamp; |
|
47 |
|
|
48 |
rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret"); |
|
49 |
return $ret; |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
function rcube_sqlite_now() |
|
54 |
{ |
|
55 |
rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s")); |
|
56 |
return date("Y-m-d H:i:s"); |
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
function rcube_sqlite_md5($str) |
|
61 |
{ |
|
62 |
return md5($str); |
|
63 |
} |
|
64 |
|
|
65 |
|
|
66 |
function rcube_sqlite_debug($str) |
|
67 |
{ |
|
68 |
//console($str); |
|
69 |
} |
|
70 |
|
|
71 |
?> |