private function __connect() {
        if (!is_null($db)) return true;

        $config = Config::get('db');

        if (is_null($config)) {
            throw new \Lollipop\Exception\Configuration('Lollipop is initialized with wrong database configuration');
        }

        $host = isset($config->host) ?  $config->host : 'localhost';
        $uid = isset($config->username) ?  $config->username : 'root';
        $pwd = isset($config->password) ?  $config->password : '';
        $db = isset($config->database) ?  $config->database : 'lollipop';
        
        // Instantiate MySQLi
        $this->db = new \mysqli($host, $uid, $pwd, $db);
        
        if ($this->db->connect_errno > 0) {
            throw new \Lollipop\Exception\Connection($this->db->connect_error);
        }

        return true;
    }
private function __connect() {
        if (!is_null($db)) return true;

        $config = Config::get('db');

        if (is_null($config)) {
            throw new \Lollipop\Exception\Configuration('Lollipop is initialized with wrong database configuration');
        }

        $host = isset($config->host) ?  $config->host : 'localhost';
        $uid = isset($config->username) ?  $config->username : 'root';
        $pwd = isset($config->password) ?  $config->password : '';
        $db = isset($config->database) ?  $config->database : 'lollipop';
        
        // Instantiate MySQLi
        $this->db = new \mysqli($host, $uid, $pwd, $db);
        
        if ($this->db->connect_errno > 0) {
            throw new \Lollipop\Exception\Connection($this->db->connect_error);
        }

        return true;
    }
private function __connect ( ) { if ( ! is_null ( $ db ) ) return true ; $ config = Config :: get ( 'db' ) ; if ( is_null ( $ config ) ) { throw new \ Lollipop \ Exception \ Configuration ( 'Lollipop is initialized with wrong database configuration' ) ; } $ host = isset ( $ config -> host ) ? $ config -> host : 'localhost' ; $ uid = isset ( $ config -> username ) ? $ config -> username : 'root' ; $ pwd = isset ( $ config -> password ) ? $ config -> password : '' ; $ db = isset ( $ config -> database ) ? $ config -> database : 'lollipop' ; // Instantiate MySQLi $ this -> db = new \ mysqli ( $ host , $ uid , $ pwd , $ db ) ; if ( $ this -> db -> connect_errno > 0 ) { throw new \ Lollipop \ Exception \ Connection ( $ this -> db -> connect_error ) ; } return true ; }
Connect to MySQL server

@throws  \Lollipop\Exception\Configuration
@throws  \Lollipop\Exception\Connection
@return  boolean
Connect to MySQL server