roundcubemail/program/include/rcmail_utils.php
public static function db()
    {
        if (self::$db === null) {
            $rc = rcube::get_instance();
            $db = rcube_db::factory($rc->config->get('db_dsnw'));

            $db->set_debug((bool)$rc->config->get('sql_debug'));

            // Connect to database
            $db->db_connect('w');

            if (!$db->is_connected()) {
                rcube::raise_error("Error connecting to database: " . $db->is_error(), false, true);
            }

            self::$db = $db;
        }

        return self::$db;
    }
public static function db()
    {
        if (self::$db === null) {
            $rc = rcube::get_instance();
            $db = rcube_db::factory($rc->config->get('db_dsnw'));

            $db->set_debug((bool)$rc->config->get('sql_debug'));

            // Connect to database
            $db->db_connect('w');

            if (!$db->is_connected()) {
                rcube::raise_error("Error connecting to database: " . $db->is_error(), false, true);
            }

            self::$db = $db;
        }

        return self::$db;
    }
public static function db ( ) { if ( self :: $ db === null ) { $ rc = rcube :: get_instance ( ) ; $ db = rcube_db :: factory ( $ rc -> config -> get ( 'db_dsnw' ) ) ; $ db -> set_debug ( ( bool ) $ rc -> config -> get ( 'sql_debug' ) ) ; // Connect to database $ db -> db_connect ( 'w' ) ; if ( ! $ db -> is_connected ( ) ) { rcube :: raise_error ( "Error connecting to database: " . $ db -> is_error ( ) , false , true ) ; } self :: $ db = $ db ; } return self :: $ db ; }
Initialize database object and connect

@return rcube_db Database instance
Initialize database object and connect