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 | |
5349b7
|
8 |
| Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | |
1cded8
|
9 |
| Licensed under the GNU GPL | |
T |
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 |
|
6d969b
|
23 |
/** |
T |
24 |
* Callback functions for sqlite database interface |
|
25 |
* |
|
26 |
* @package Database |
|
27 |
*/ |
|
28 |
|
1cded8
|
29 |
|
T |
30 |
function rcube_sqlite_from_unixtime($timestamp) |
|
31 |
{ |
6d969b
|
32 |
$timestamp = trim($timestamp); |
T |
33 |
if (!preg_match("/^[0-9]+$/is", $timestamp)) |
|
34 |
$ret = strtotime($timestamp); |
|
35 |
else |
|
36 |
$ret = $timestamp; |
|
37 |
|
|
38 |
$ret = date("Y-m-d H:i:s", $ret); |
|
39 |
rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret"); |
|
40 |
return $ret; |
1cded8
|
41 |
} |
T |
42 |
|
|
43 |
|
|
44 |
function rcube_sqlite_unix_timestamp($timestamp="") |
|
45 |
{ |
6d969b
|
46 |
$timestamp = trim($timestamp); |
T |
47 |
if (!$timestamp) |
|
48 |
$ret = time(); |
|
49 |
else if (!preg_match("/^[0-9]+$/is", $timestamp)) |
|
50 |
$ret = strtotime($timestamp); |
|
51 |
else |
|
52 |
$ret = $timestamp; |
1cded8
|
53 |
|
6d969b
|
54 |
rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret"); |
T |
55 |
return $ret; |
1cded8
|
56 |
} |
T |
57 |
|
|
58 |
|
|
59 |
function rcube_sqlite_now() |
|
60 |
{ |
6d969b
|
61 |
rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s")); |
T |
62 |
return date("Y-m-d H:i:s"); |
1cded8
|
63 |
} |
T |
64 |
|
|
65 |
|
|
66 |
function rcube_sqlite_md5($str) |
|
67 |
{ |
6d969b
|
68 |
return md5($str); |
1cded8
|
69 |
} |
T |
70 |
|
|
71 |
|
|
72 |
function rcube_sqlite_debug($str) |
|
73 |
{ |
6d969b
|
74 |
//console($str); |
1cded8
|
75 |
} |
6d969b
|
76 |
|
5349b7
|
77 |
?> |