summaryrefslogtreecommitdiff
path: root/program/include/rcube_sqlite.inc
blob: 2b0d044c13ddf1d717cbb2c922901fa849760d04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php

/*
 +-----------------------------------------------------------------------+
 | program/include/rcube_sqlite.inc                                      |
 |                                                                       |
 | This file is part of the RoundCube Webmail client                     |
 | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | PURPOSE:                                                              |
 |   Provide callback functions for sqlite that will emulate             |
 |   sone MySQL functions                                                |
 |                                                                       |
 +-----------------------------------------------------------------------+
 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
 +-----------------------------------------------------------------------+

 $Id$

*/

/**
 * Callback functions for sqlite database interface
 *
 * @package Database
 */


function rcube_sqlite_from_unixtime($timestamp)
  {
  $timestamp = trim($timestamp);
  if (!preg_match("/^[0-9]+$/is", $timestamp))
    $ret = strtotime($timestamp);
  else
    $ret = $timestamp;
    
  $ret = date("Y-m-d H:i:s", $ret);
  rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret");
  return $ret;
  }


function rcube_sqlite_unix_timestamp($timestamp="")
  {
  $timestamp = trim($timestamp);
  if (!$timestamp)
    $ret = time();
  else if (!preg_match("/^[0-9]+$/is", $timestamp))
    $ret = strtotime($timestamp);
  else
    $ret = $timestamp;

  rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret");
  return $ret;
  }


function rcube_sqlite_now()
  {
  rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s"));
  return date("Y-m-d H:i:s");
  }


function rcube_sqlite_md5($str)
  {
  return md5($str);
  }


function rcube_sqlite_debug($str)
  {
  //console($str);
  }
  
?>