Aleksander Machniak
2012-08-27 8eefbb2158c43b51a8c33e6c480cbe61539b9535
program/include/rcube_db_sqlite.php
@@ -1,6 +1,6 @@
<?php
/*
/**
 +-----------------------------------------------------------------------+
 | program/include/rcube_db_sqlite.php                                   |
 |                                                                       |
@@ -26,24 +26,37 @@
 *
 * This is a wrapper for the PHP PDO
 *
 * @package    Database
 * @version    1.0
 * @package Database
 * @version 1.0
 */
class rcube_db_sqlite extends rcube_db
{
    /**
     * Database character set
     */
    protected function set_charset($charset)
    {
    }
    /**
     * Prepare connection
     */
    protected function conn_prepare($dsn)
    {
        // Create database file, required by PDO to exist on connection
        if (!empty($dsn['database']) && !file_exists($dsn['database'])) {
            touch($dsn['database']);
            $created = touch($dsn['database']);
            // File mode setting, for compat. with MDB2
            if (!empty($dsn['mode']) && $created) {
                chmod($dsn['database'], octdec($dsn['mode']));
            }
        }
    }
    /**
     * Configure connection, create database if not exists
     */
    protected function conn_configure($dsn, $dbh)
    {
        // we emulate via callback some missing functions
@@ -55,14 +68,12 @@
            $data = file_get_contents(INSTALL_PATH . 'SQL/sqlite.initial.sql');
            if (strlen($data)) {
                if ($this->options['debug_mode']) {
                    $this::debug('INITIALIZE DATABASE');
                }
                $this->debug('INITIALIZE DATABASE');
                $q = $dbh->exec($data);
                if ($q === false) {
                    $error = $this->dbh->errorInfo();
                    $error = $dbh->errorInfo();
                    $this->db_error = true;
                    $this->db_error_msg = sprintf('[%s] %s', $error[1], $error[2]);
@@ -73,7 +84,6 @@
            }
        }
    }
    /**
     * Callback for sqlite: unix_timestamp()
@@ -94,7 +104,6 @@
        return $ret;
    }
    /**
     * Callback for sqlite: now()
     */
@@ -102,7 +111,6 @@
    {
        return date("Y-m-d H:i:s");
    }
    /**
     * Returns list of tables in database
@@ -126,11 +134,10 @@
        return $this->tables;
    }
    /**
     * Returns list of columns in database table
     *
     * @param string Table name
     * @param string $table Table name
     *
     * @return array List of table cols
     */
@@ -161,7 +168,9 @@
        return $columns;
    }
    /**
     * Build DSN string for PDO constructor
     */
    protected function dsn_string($dsn)
    {
        return $dsn['phptype'] . ':' . $dsn['database'];