]> git.donarmstrong.com Git - roundcube.git/blob - debian/patches/use_php_timestamp_implementation_for_sqlite.patch
Imported Debian patch 0.1~rc1~dfsg-1
[roundcube.git] / debian / patches / use_php_timestamp_implementation_for_sqlite.patch
1 diff -urN roundcube-0.1~rc1~dfsg.old/program/include/rcube_db.inc roundcube-0.1~rc1~dfsg/program/include/rcube_db.inc
2 --- roundcube-0.1~rc1~dfsg.old/program/include/rcube_db.inc     2007-05-24 21:27:53.000000000 +0200
3 +++ roundcube-0.1~rc1~dfsg/program/include/rcube_db.inc 2007-05-24 21:29:36.000000000 +0200
4 @@ -27,6 +27,13 @@
5   */
6  require_once('DB.php');
7  
8 +/* User function for getting timestamps under sqlite */
9 +function custom_date_to_timestamp($data) {
10 +   $date = strptime($data,'%Y-%m-%d %H:%M:%S');
11 +   return mktime($date['tm_hour'],$date['tm_min'],$date['tm_sec'],$date['tm_mon']+1,$date['tm_mday'],1900 + $date['tm_year']);
12 +}
13 +
14 +
15  
16  /**
17   * Database independent query interface
18 @@ -152,6 +159,9 @@
19        $dsn = $this->db_dsnw;
20  
21      $this->db_handle = $this->dsn_connect($dsn);
22 +    if ($this->db_provider == "sqlite") {
23 +        sqlite_create_function($this->db_handle->connection,'custom_date_to_timestamp','custom_date_to_timestamp',1);    
24 +    }
25      $this->db_connected = $this->db_handle ? TRUE : FALSE;
26      }
27      
28 @@ -462,6 +472,9 @@
29        case 'mssql':
30          return "datediff(s, '1970-01-01 00:00:00', $field)";
31  
32 +      case 'sqlite':
33 +        return "custom_date_to_timestamp($field)";
34 +
35        default:
36          return "UNIX_TIMESTAMP($field)";
37        }