roundcubemail/program/include/rcmail_utils.php
protected static function db_update_schema($package, $version, $file)
    {
        $db = self::db();

        // read DDL file
        if ($sql = file_get_contents($file)) {
            if (!$db->exec_script($sql)) {
                return $db->is_error();
            }
        }

        // escape if 'system' table does not exist
        if ($version < 2013011000) {
            return;
        }

        $system_table = $db->table_name('system', true);

        $db->query("UPDATE " . $system_table
            . " SET `value` = ?"
            . " WHERE `name` = ?",
            $version, $package . '-version');

        if (!$db->is_error() && !$db->affected_rows()) {
            $db->query("INSERT INTO " . $system_table
                ." (`name`, `value`) VALUES (?, ?)",
                $package . '-version', $version);
        }

        return $db->is_error();
    }
protected static function db_update_schema($package, $version, $file)
    {
        $db = self::db();

        // read DDL file
        if ($sql = file_get_contents($file)) {
            if (!$db->exec_script($sql)) {
                return $db->is_error();
            }
        }

        // escape if 'system' table does not exist
        if ($version < 2013011000) {
            return;
        }

        $system_table = $db->table_name('system', true);

        $db->query("UPDATE " . $system_table
            . " SET `value` = ?"
            . " WHERE `name` = ?",
            $version, $package . '-version');

        if (!$db->is_error() && !$db->affected_rows()) {
            $db->query("INSERT INTO " . $system_table
                ." (`name`, `value`) VALUES (?, ?)",
                $package . '-version', $version);
        }

        return $db->is_error();
    }
protected static function db_update_schema ( $ package , $ version , $ file ) { $ db = self :: db ( ) ; // read DDL file if ( $ sql = file_get_contents ( $ file ) ) { if ( ! $ db -> exec_script ( $ sql ) ) { return $ db -> is_error ( ) ; } } // escape if 'system' table does not exist if ( $ version < 2013011000 ) { return ; } $ system_table = $ db -> table_name ( 'system' , true ) ; $ db -> query ( "UPDATE " . $ system_table . " SET `value` = ?" . " WHERE `name` = ?" , $ version , $ package . '-version' ) ; if ( ! $ db -> is_error ( ) && ! $ db -> affected_rows ( ) ) { $ db -> query ( "INSERT INTO " . $ system_table . " (`name`, `value`) VALUES (?, ?)" , $ package . '-version' , $ version ) ; } return $ db -> is_error ( ) ; }
Run database update from a single sql file
Run database update from a single sql file