commit | author | age
|
1cded8
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/include/rcube_sqlite.inc | |
|
6 |
| | |
e019f2
|
7 |
| This file is part of the Roundcube Webmail client | |
A |
8 |
| Copyright (C) 2005-2010, 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) |
2eb794
|
31 |
{ |
A |
32 |
$timestamp = trim($timestamp); |
|
33 |
if (!preg_match('/^[0-9]+$/is', $timestamp)) |
|
34 |
$ret = strtotime($timestamp); |
|
35 |
else |
|
36 |
$ret = $timestamp; |
6d969b
|
37 |
|
2eb794
|
38 |
$ret = date('Y-m-d H:i:s', $ret); |
A |
39 |
rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret"); |
|
40 |
return $ret; |
|
41 |
} |
1cded8
|
42 |
|
T |
43 |
|
2eb794
|
44 |
function rcube_sqlite_unix_timestamp($timestamp='') |
A |
45 |
{ |
|
46 |
$timestamp = trim($timestamp); |
|
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 |
|
2eb794
|
54 |
rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret"); |
A |
55 |
return $ret; |
|
56 |
} |
1cded8
|
57 |
|
T |
58 |
|
|
59 |
function rcube_sqlite_now() |
2eb794
|
60 |
{ |
A |
61 |
rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s")); |
|
62 |
return date("Y-m-d H:i:s"); |
|
63 |
} |
1cded8
|
64 |
|
T |
65 |
|
|
66 |
function rcube_sqlite_md5($str) |
2eb794
|
67 |
{ |
A |
68 |
return md5($str); |
|
69 |
} |
1cded8
|
70 |
|
T |
71 |
|
|
72 |
function rcube_sqlite_debug($str) |
2eb794
|
73 |
{ |
A |
74 |
//console($str); |
|
75 |
} |
b25dfd
|
76 |
|