source: github/program/include/rcube_mdb2.php @ b4b5ba7

HEADdev-browser-capabilitiespdo
Last change on this file since b4b5ba7 was b4b5ba7, checked in by Thomas Bruederli <thomas@…>, 13 months ago

Add getter for database runtime/config variables

  • Property mode set to 100644
File size: 25.2 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/include/rcube_mdb2.php                                        |
6 |                                                                       |
7 | This file is part of the Roundcube Webmail client                     |
8 | Copyright (C) 2005-2009, The Roundcube Dev Team                       |
9 |                                                                       |
10 | Licensed under the GNU General Public License version 3 or            |
11 | any later version with exceptions for skins & plugins.                |
12 | See the README file for a full license statement.                     |
13 |                                                                       |
14 | PURPOSE:                                                              |
15 |   PEAR:DB wrapper class that implements PEAR MDB2 functions           |
16 |   See http://pear.php.net/package/MDB2                                |
17 |                                                                       |
18 +-----------------------------------------------------------------------+
19 | Author: Lukas Kahwe Smith <smith@pooteeweet.org>                      |
20 +-----------------------------------------------------------------------+
21*/
22
23
24/**
25 * Database independent query interface
26 *
27 * This is a wrapper for the PEAR::MDB2 class
28 *
29 * @package    Database
30 * @author     David Saez Padros <david@ols.es>
31 * @author     Thomas Bruederli <roundcube@gmail.com>
32 * @author     Lukas Kahwe Smith <smith@pooteeweet.org>
33 * @version    1.18
34 * @link       http://pear.php.net/package/MDB2
35 */
36class rcube_mdb2
37{
38    public $db_dsnw;               // DSN for write operations
39    public $db_dsnr;               // DSN for read operations
40    public $db_connected = false;  // Already connected ?
41    public $db_mode = '';          // Connection mode
42    public $db_handle = 0;         // Connection handle
43    public $db_error = false;
44    public $db_error_msg = '';
45
46    private $debug_mode = false;
47    private $conn_failure = false;
48    private $a_query_results = array('dummy');
49    private $last_res_id = 0;
50    private $tables;
51    private $variables;
52
53
54    /**
55     * Object constructor
56     *
57     * @param  string $db_dsnw DSN for read/write operations
58     * @param  string $db_dsnr Optional DSN for read only operations
59     */
60    public function __construct($db_dsnw, $db_dsnr='', $pconn=false)
61    {
62        if (empty($db_dsnr)) {
63            $db_dsnr = $db_dsnw;
64        }
65
66        $this->db_dsnw = $db_dsnw;
67        $this->db_dsnr = $db_dsnr;
68        $this->db_pconn = $pconn;
69
70        $dsn_array = MDB2::parseDSN($db_dsnw);
71        $this->db_provider = $dsn_array['phptype'];
72    }
73
74
75    /**
76     * Connect to specific database
77     *
78     * @param  string $dsn  DSN for DB connections
79     * @return MDB2 PEAR database handle
80     * @access private
81     */
82    private function dsn_connect($dsn)
83    {
84        // Use persistent connections if available
85        $db_options = array(
86            'persistent'       => $this->db_pconn,
87            'emulate_prepared' => $this->debug_mode,
88            'debug'            => $this->debug_mode,
89            'debug_handler'    => array($this, 'debug_handler'),
90            'portability'      => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL,
91        );
92
93        if ($this->db_provider == 'pgsql') {
94            $db_options['disable_smart_seqname'] = true;
95            $db_options['seqname_format'] = '%s';
96        }
97        $this->db_error     = false;
98        $this->db_error_msg = null;
99
100        $dbh = MDB2::connect($dsn, $db_options);
101
102        if (MDB2::isError($dbh)) {
103            $this->db_error = true;
104            $this->db_error_msg = $dbh->getMessage();
105
106            rcube::raise_error(array('code' => 500, 'type' => 'db',
107                'line' => __LINE__, 'file' => __FILE__,
108                'message' => $dbh->getUserInfo()), true, false);
109        }
110        else if ($this->db_provider == 'sqlite') {
111            $dsn_array = MDB2::parseDSN($dsn);
112            if (!filesize($dsn_array['database']) && !empty($this->sqlite_initials)) {
113                $this->sqlite_create_database($dbh, $this->sqlite_initials);
114            }
115        }
116        else if ($this->db_provider != 'mssql' && $this->db_provider != 'sqlsrv') {
117            $dbh->setCharset('utf8');
118        }
119
120        return $dbh;
121    }
122
123
124    /**
125     * Connect to appropiate database depending on the operation
126     *
127     * @param  string $mode Connection mode (r|w)
128     */
129    public function db_connect($mode)
130    {
131        // previous connection failed, don't attempt to connect again
132        if ($this->conn_failure) {
133            return;
134        }
135
136        // no replication
137        if ($this->db_dsnw == $this->db_dsnr) {
138            $mode = 'w';
139        }
140
141        // Already connected
142        if ($this->db_connected) {
143            // connected to db with the same or "higher" mode
144            if ($this->db_mode == 'w' || $this->db_mode == $mode) {
145                return;
146            }
147        }
148
149        $dsn = ($mode == 'r') ? $this->db_dsnr : $this->db_dsnw;
150
151        $this->db_handle    = $this->dsn_connect($dsn);
152        $this->db_connected = !PEAR::isError($this->db_handle);
153
154        // use write-master when read-only fails
155        if (!$this->db_connected && $mode == 'r') {
156            $mode = 'w';
157            $this->db_handle    = $this->dsn_connect($this->db_dsnw);
158            $this->db_connected = !PEAR::isError($this->db_handle);
159        }
160
161        if ($this->db_connected) {
162            $this->db_mode = $mode;
163        }
164        else {
165            $this->conn_failure = true;
166        }
167    }
168
169
170    /**
171     * Activate/deactivate debug mode
172     *
173     * @param boolean $dbg True if SQL queries should be logged
174     */
175    public function set_debug($dbg = true)
176    {
177        $this->debug_mode = $dbg;
178        if ($this->db_connected) {
179            $this->db_handle->setOption('debug', $dbg);
180            $this->db_handle->setOption('emulate_prepared', $dbg);
181        }
182    }
183
184
185    /**
186     * Getter for error state
187     *
188     * @param  boolean  True on error
189     */
190    public function is_error()
191    {
192        return $this->db_error ? $this->db_error_msg : false;
193    }
194
195
196    /**
197     * Connection state checker
198     *
199     * @param  boolean  True if in connected state
200     */
201    public function is_connected()
202    {
203        return PEAR::isError($this->db_handle) ? false : $this->db_connected;
204    }
205
206
207    /**
208     * Is database replication configured?
209     * This returns true if dsnw != dsnr
210     */
211    public function is_replicated()
212    {
213      return !empty($this->db_dsnr) && $this->db_dsnw != $this->db_dsnr;
214    }
215
216
217    /**
218     * Get database runtime variables
219     *
220     * @param string Variable name
221     * @param mixed  Default value if var is not set
222     * @return mixed Variable value or default
223     */
224    public function get_variable($varname, $default = null)
225    {
226        if (!isset($this->variables)) {
227            $this->variables = array();
228
229            // only mysql and postgres are know to support this
230            if ($this->db_provider == 'pgsql' || $this->db_provider == 'mysql' || $this->db_provider == 'mysqli') {
231                $this->db_connect('r');
232                $query = $this->db_provider == 'pgsql' ? 'SHOW ALL' : 'SHOW VARIABLES';
233                foreach ((array)$this->db_handle->queryAll($query) as $row)
234                    $this->variables[$row[0]] = $row[1];
235            }
236        }
237
238        return isset($this->variables[$varname]) ? $this->variables[$varname] : $default;
239    }
240
241
242    /**
243     * Execute a SQL query
244     *
245     * @param  string  SQL query to execute
246     * @param  mixed   Values to be inserted in query
247     *
248     * @return number  Query handle identifier
249     */
250    public function query()
251    {
252        $params = func_get_args();
253        $query = array_shift($params);
254
255        // Support one argument of type array, instead of n arguments
256        if (count($params) == 1 && is_array($params[0])) {
257            $params = $params[0];
258        }
259
260        return $this->_query($query, 0, 0, $params);
261    }
262
263
264    /**
265     * Execute a SQL query with limits
266     *
267     * @param  string  SQL query to execute
268     * @param  number  Offset for LIMIT statement
269     * @param  number  Number of rows for LIMIT statement
270     * @param  mixed   Values to be inserted in query
271     *
272     * @return number  Query handle identifier
273     */
274    public function limitquery()
275    {
276        $params  = func_get_args();
277        $query   = array_shift($params);
278        $offset  = array_shift($params);
279        $numrows = array_shift($params);
280
281        return $this->_query($query, $offset, $numrows, $params);
282    }
283
284
285    /**
286     * Execute a SQL query with limits
287     *
288     * @param  string $query   SQL query to execute
289     * @param  number $offset  Offset for LIMIT statement
290     * @param  number $numrows Number of rows for LIMIT statement
291     * @param  array  $params  Values to be inserted in query
292     * @return number  Query handle identifier
293     * @access private
294     */
295    private function _query($query, $offset, $numrows, $params)
296    {
297        // Read or write ?
298        $mode = (strtolower(substr(trim($query),0,6)) == 'select') ? 'r' : 'w';
299
300        $this->db_connect($mode);
301
302        // check connection before proceeding
303        if (!$this->is_connected()) {
304            return null;
305        }
306
307        if ($this->db_provider == 'sqlite') {
308            $this->sqlite_prepare();
309        }
310
311        if ($numrows || $offset) {
312            $result = $this->db_handle->setLimit($numrows,$offset);
313        }
314
315        if (empty($params)) {
316            $result = $mode == 'r' ? $this->db_handle->query($query) : $this->db_handle->exec($query);
317        }
318        else {
319            $params = (array)$params;
320            $q = $this->db_handle->prepare($query, null, $mode=='w' ? MDB2_PREPARE_MANIP : null);
321            if ($this->db_handle->isError($q)) {
322                $this->db_error = true;
323                $this->db_error_msg = $q->userinfo;
324
325                rcube::raise_error(array('code' => 500, 'type' => 'db',
326                    'line' => __LINE__, 'file' => __FILE__,
327                    'message' => $this->db_error_msg), true, false);
328
329                $result = false;
330            }
331            else {
332                $result = $q->execute($params);
333                $q->free();
334            }
335        }
336
337        // add result, even if it's an error
338        return $this->_add_result($result);
339    }
340
341
342    /**
343     * Get number of rows for a SQL query
344     * If no query handle is specified, the last query will be taken as reference
345     *
346     * @param  number $res_id  Optional query handle identifier
347     * @return mixed   Number of rows or false on failure
348     */
349    public function num_rows($res_id=null)
350    {
351        if (!$this->db_connected) {
352            return false;
353        }
354
355        if ($result = $this->_get_result($res_id)) {
356            return $result->numRows();
357        }
358
359        return false;
360    }
361
362
363    /**
364     * Get number of affected rows for the last query
365     *
366     * @param  number $res_id Optional query handle identifier
367     * @return mixed   Number of rows or false on failure
368     */
369    public function affected_rows($res_id = null)
370    {
371        if (!$this->db_connected) {
372            return false;
373        }
374
375        return $this->_get_result($res_id);
376    }
377
378
379    /**
380     * Get last inserted record ID
381     * For Postgres databases, a sequence name is required
382     *
383     * @param  string $table  Table name (to find the incremented sequence)
384     *
385     * @return mixed   ID or false on failure
386     */
387    public function insert_id($table = '')
388    {
389        if (!$this->db_connected || $this->db_mode == 'r') {
390            return false;
391        }
392
393        if ($table) {
394            if ($this->db_provider == 'pgsql') {
395                // find sequence name
396                $table = $this->sequence_name($table);
397            }
398            else {
399                // resolve table name
400                $table = $this->table_name($table);
401            }
402        }
403
404        $id = $this->db_handle->lastInsertID($table);
405
406        return $this->db_handle->isError($id) ? null : $id;
407    }
408
409
410    /**
411     * Get an associative array for one row
412     * If no query handle is specified, the last query will be taken as reference
413     *
414     * @param  number $res_id Optional query handle identifier
415     *
416     * @return mixed   Array with col values or false on failure
417     */
418    public function fetch_assoc($res_id = null)
419    {
420        $result = $this->_get_result($res_id);
421        return $this->_fetch_row($result, MDB2_FETCHMODE_ASSOC);
422    }
423
424
425    /**
426     * Get an index array for one row
427     * If no query handle is specified, the last query will be taken as reference
428     *
429     * @param  number $res_id  Optional query handle identifier
430     *
431     * @return mixed   Array with col values or false on failure
432     */
433    public function fetch_array($res_id = null)
434    {
435        $result = $this->_get_result($res_id);
436        return $this->_fetch_row($result, MDB2_FETCHMODE_ORDERED);
437    }
438
439
440    /**
441     * Get col values for a result row
442     *
443     * @param  MDB2_Result_Common Query $result result handle
444     * @param  number                   $mode   Fetch mode identifier
445     *
446     * @return mixed  Array with col values or false on failure
447     */
448    private function _fetch_row($result, $mode)
449    {
450        if ($result === false || PEAR::isError($result) || !$this->is_connected()) {
451            return false;
452        }
453
454        return $result->fetchRow($mode);
455    }
456
457
458    /**
459     * Wrapper for the SHOW TABLES command
460     *
461     * @return array List of all tables of the current database
462     * @since 0.4-beta
463     */
464    public function list_tables()
465    {
466        // get tables if not cached
467        if (!$this->tables) {
468            $this->db_handle->loadModule('Manager');
469            if (!PEAR::isError($result = $this->db_handle->listTables())) {
470                $this->tables = $result;
471            }
472            else {
473                $this->tables = array();
474            }
475        }
476
477        return $this->tables;
478    }
479
480
481    /**
482     * Wrapper for SHOW COLUMNS command
483     *
484     * @param string Table name
485     *
486     * @return array List of table cols
487     */
488    public function list_cols($table)
489    {
490        $this->db_handle->loadModule('Manager');
491        if (!PEAR::isError($result = $this->db_handle->listTableFields($table))) {
492            return $result;
493        }
494
495        return null;
496    }
497
498
499    /**
500     * Formats input so it can be safely used in a query
501     *
502     * @param  mixed  $input  Value to quote
503     * @param  string $type   Type of data
504     *
505     * @return string  Quoted/converted string for use in query
506     */
507    public function quote($input, $type = null)
508    {
509        // handle int directly for better performance
510        if ($type == 'integer') {
511            return intval($input);
512        }
513
514        // create DB handle if not available
515        if (!$this->db_handle) {
516            $this->db_connect('r');
517        }
518
519        return $this->db_connected ? $this->db_handle->quote($input, $type) : addslashes($input);
520    }
521
522
523    /**
524     * Quotes a string so it can be safely used as a table or column name
525     *
526     * @param  string $str Value to quote
527     *
528     * @return string  Quoted string for use in query
529     * @deprecated     Replaced by rcube_MDB2::quote_identifier
530     * @see            rcube_mdb2::quote_identifier
531     */
532    public function quoteIdentifier($str)
533    {
534        return $this->quote_identifier($str);
535    }
536
537
538    /**
539     * Quotes a string so it can be safely used as a table or column name
540     *
541     * @param  string $str Value to quote
542     *
543     * @return string  Quoted string for use in query
544     */
545    public function quote_identifier($str)
546    {
547        if (!$this->db_handle) {
548            $this->db_connect('r');
549        }
550
551        return $this->db_connected ? $this->db_handle->quoteIdentifier($str) : $str;
552    }
553
554
555    /**
556     * Escapes a string
557     *
558     * @param  string $str The string to be escaped
559     *
560     * @return string  The escaped string
561     * @since  0.1.1
562     */
563    public function escapeSimple($str)
564    {
565        if (!$this->db_handle) {
566            $this->db_connect('r');
567        }
568
569        return $this->db_handle->escape($str);
570    }
571
572
573    /**
574     * Return SQL function for current time and date
575     *
576     * @return string SQL function to use in query
577     */
578    public function now()
579    {
580        switch ($this->db_provider) {
581            case 'mssql':
582            case 'sqlsrv':
583                return "getdate()";
584
585            default:
586                return "now()";
587        }
588    }
589
590
591    /**
592     * Return list of elements for use with SQL's IN clause
593     *
594     * @param  array  $arr  Input array
595     * @param  string $type Type of data
596     *
597     * @return string Comma-separated list of quoted values for use in query
598     */
599    public function array2list($arr, $type = null)
600    {
601        if (!is_array($arr)) {
602            return $this->quote($arr, $type);
603        }
604
605        foreach ($arr as $idx => $item) {
606            $arr[$idx] = $this->quote($item, $type);
607        }
608
609        return implode(',', $arr);
610    }
611
612
613    /**
614     * Return SQL statement to convert a field value into a unix timestamp
615     *
616     * This method is deprecated and should not be used anymore due to limitations
617     * of timestamp functions in Mysql (year 2038 problem)
618     *
619     * @param  string $field Field name
620     *
621     * @return string  SQL statement to use in query
622     * @deprecated
623     */
624    public function unixtimestamp($field)
625    {
626        switch($this->db_provider) {
627            case 'pgsql':
628                return "EXTRACT (EPOCH FROM $field)";
629
630            case 'mssql':
631            case 'sqlsrv':
632                return "DATEDIFF(second, '19700101', $field) + DATEDIFF(second, GETDATE(), GETUTCDATE())";
633
634            default:
635                return "UNIX_TIMESTAMP($field)";
636        }
637    }
638
639
640    /**
641     * Return SQL statement to convert from a unix timestamp
642     *
643     * @param  string $timestamp Field name
644     *
645     * @return string  SQL statement to use in query
646     */
647    public function fromunixtime($timestamp)
648    {
649        return date("'Y-m-d H:i:s'", $timestamp);
650    }
651
652
653    /**
654     * Return SQL statement for case insensitive LIKE
655     *
656     * @param  string $column  Field name
657     * @param  string $value   Search value
658     *
659     * @return string  SQL statement to use in query
660     */
661    public function ilike($column, $value)
662    {
663        // TODO: use MDB2's matchPattern() function
664        switch ($this->db_provider) {
665            case 'pgsql':
666                return $this->quote_identifier($column).' ILIKE '.$this->quote($value);
667            default:
668                return $this->quote_identifier($column).' LIKE '.$this->quote($value);
669        }
670    }
671
672
673    /**
674     * Abstract SQL statement for value concatenation
675     *
676     * @return string SQL statement to be used in query
677     */
678    public function concat(/* col1, col2, ... */)
679    {
680        $func = '';
681        $args = func_get_args();
682        if (is_array($args[0]))
683            $args = $args[0];
684
685        switch ($this->db_provider) {
686            case 'mysql':
687            case 'mysqli':
688                $func = 'CONCAT';
689                $delim = ', ';
690                break;
691            case 'mssql':
692            case 'sqlsrv':
693                $delim = ' + ';
694                break;
695            default:
696                $delim = ' || ';
697        }
698
699        return $func . '(' . join($delim, $args) . ')';
700    }
701
702
703    /**
704     * Encodes non-UTF-8 characters in string/array/object (recursive)
705     *
706     * @param  mixed  $input Data to fix
707     *
708     * @return mixed  Properly UTF-8 encoded data
709     */
710    public static function encode($input)
711    {
712        if (is_object($input)) {
713            foreach (get_object_vars($input) as $idx => $value) {
714                $input->$idx = self::encode($value);
715            }
716            return $input;
717        }
718        else if (is_array($input)) {
719            foreach ($input as $idx => $value) {
720                $input[$idx] = self::encode($value);
721            }
722            return $input;
723        }
724
725        return utf8_encode($input);
726    }
727
728
729    /**
730     * Decodes encoded UTF-8 string/object/array (recursive)
731     *
732     * @param  mixed $input Input data
733     *
734     * @return mixed  Decoded data
735     */
736    public static function decode($input)
737    {
738        if (is_object($input)) {
739            foreach (get_object_vars($input) as $idx => $value) {
740                $input->$idx = self::decode($value);
741            }
742            return $input;
743        }
744        else if (is_array($input)) {
745            foreach ($input as $idx => $value) {
746                $input[$idx] = self::decode($value);
747            }
748            return $input;
749        }
750
751        return utf8_decode($input);
752    }
753
754
755    /**
756     * Adds a query result and returns a handle ID
757     *
758     * @param  object $res Query handle
759     *
760     * @return mixed   Handle ID
761     */
762    private function _add_result($res)
763    {
764        // sql error occured
765        if (PEAR::isError($res)) {
766            $this->db_error = true;
767            $this->db_error_msg = $res->getMessage();
768            rcube::raise_error(array('code' => 500, 'type' => 'db',
769                'line' => __LINE__, 'file' => __FILE__,
770                'message' => $res->getMessage() . " Query: " 
771                . substr(preg_replace('/[\r\n]+\s*/', ' ', $res->userinfo), 0, 512)),
772                true, false);
773        }
774
775        $res_id = sizeof($this->a_query_results);
776        $this->last_res_id = $res_id;
777        $this->a_query_results[$res_id] = $res;
778        return $res_id;
779    }
780
781
782    /**
783     * Resolves a given handle ID and returns the according query handle
784     * If no ID is specified, the last resource handle will be returned
785     *
786     * @param  number $res_id Handle ID
787     *
788     * @return mixed   Resource handle or false on failure
789     */
790    private function _get_result($res_id = null)
791    {
792        if ($res_id == null) {
793            $res_id = $this->last_res_id;
794        }
795
796        if (isset($this->a_query_results[$res_id])) {
797            if (!PEAR::isError($this->a_query_results[$res_id])) {
798                return $this->a_query_results[$res_id];
799            }
800        }
801
802        return false;
803    }
804
805
806    /**
807     * Create a sqlite database from a file
808     *
809     * @param  MDB2   $dbh       SQLite database handle
810     * @param  string $file_name File path to use for DB creation
811     */
812    private function sqlite_create_database($dbh, $file_name)
813    {
814        if (empty($file_name) || !is_string($file_name)) {
815            return;
816        }
817
818        $data = file_get_contents($file_name);
819
820        if (strlen($data)) {
821            if (!sqlite_exec($dbh->connection, $data, $error) || MDB2::isError($dbh)) {
822                rcube::raise_error(array('code' => 500, 'type' => 'db',
823                    'line' => __LINE__, 'file' => __FILE__,
824                    'message' => $error), true, false);
825            }
826        }
827    }
828
829
830    /**
831     * Add some proprietary database functions to the current SQLite handle
832     * in order to make it MySQL compatible
833     */
834    private function sqlite_prepare()
835    {
836        // we emulate via callback some missing MySQL functions
837        sqlite_create_function($this->db_handle->connection,
838            'unix_timestamp', array('rcube_mdb2', 'sqlite_unix_timestamp'));
839        sqlite_create_function($this->db_handle->connection,
840            'now', array('rcube_mdb2', 'sqlite_now'));
841    }
842
843
844    /**
845     * Debug handler for the MDB2
846     */
847    function debug_handler(&$db, $scope, $message, $context = array())
848    {
849        if ($scope != 'prepare') {
850            $debug_output = sprintf('%s(%d): %s;',
851                $scope, $db->db_index, rtrim($message, ';'));
852            rcube::write_log('sql', $debug_output);
853        }
854    }
855
856
857    /**
858     * Return correct name for a specific database table
859     *
860     * @param string $table Table name
861     *
862     * @return string Translated table name
863     */
864    public function table_name($table)
865    {
866        $rcube = rcube::get_instance();
867
868        // return table name if configured
869        $config_key = 'db_table_'.$table;
870
871        if ($name = $rcube->config->get($config_key)) {
872            return $name;
873        }
874
875        return $table;
876    }
877
878
879    /**
880     * Return correct name for a specific database sequence
881     * (used for Postgres only)
882     *
883     * @param string $sequence Secuence name
884     *
885     * @return string Translated sequence name
886     */
887    public function sequence_name($sequence)
888    {
889        $rcube = rcube::get_instance();
890
891        // return sequence name if configured
892        $config_key = 'db_sequence_'.$sequence;
893
894        if ($name = $rcube->config->get($config_key)) {
895            return $name;
896        }
897
898        return $sequence;
899    }
900
901
902    /**
903     * Callback for sqlite: unix_timestamp()
904     */
905    public static function sqlite_unix_timestamp($timestamp = '')
906    {
907        $timestamp = trim($timestamp);
908        if (!$timestamp) {
909            $ret = time();
910        }
911        else if (!preg_match('/^[0-9]+$/s', $timestamp)) {
912            $ret = strtotime($timestamp);
913        }
914        else {
915            $ret = $timestamp;
916        }
917
918        return $ret;
919    }
920
921
922    /**
923     * Callback for sqlite: now()
924     */
925    public static function sqlite_now()
926    {
927        return date("Y-m-d H:i:s");
928    }
929
930}
Note: See TracBrowser for help on using the repository browser.