+ /**
+ * Create a sqlite database from a file
+ *
+ * @param MDB2 $dbh SQLite database handle
+ * @param string $file_name File path to use for DB creation
+ * @access private
+ */
+ private function _sqlite_create_database($dbh, $file_name)
+ {
+ if (empty($file_name) || !is_string($file_name))
+ return;
+
+ $data = file_get_contents($file_name);
+
+ if (strlen($data))
+ if (!sqlite_exec($dbh->connection, $data, $error) || MDB2::isError($dbh))
+ raise_error(array('code' => 500, 'type' => 'db',
+ 'line' => __LINE__, 'file' => __FILE__,
+ 'message' => $error), true, false);
+ }
+
+
+ /**
+ * Add some proprietary database functions to the current SQLite handle
+ * in order to make it MySQL compatible
+ *
+ * @access private
+ */
+ private function _sqlite_prepare()
+ {
+ include_once('include/rcube_sqlite.inc');
+
+ // we emulate via callback some missing MySQL function
+ sqlite_create_function($this->db_handle->connection,
+ 'from_unixtime', 'rcube_sqlite_from_unixtime');
+ sqlite_create_function($this->db_handle->connection,
+ 'unix_timestamp', 'rcube_sqlite_unix_timestamp');
+ sqlite_create_function($this->db_handle->connection,
+ 'now', 'rcube_sqlite_now');
+ sqlite_create_function($this->db_handle->connection,
+ 'md5', 'rcube_sqlite_md5');
+ }
+
+} // end class rcube_db