Habari\DB::connect PHP Метод

connect() публичный статический Метод

Connects to the database server. If no arguments are supplied, then the connection is attempted for the database authentication variables in config.php.
public static connect ( ) : boolean
Результат boolean
    public static function connect()
    {
        /*
        	if connection has been instantiated (ie: not null), check if is already connected
        */
        if (null != DB::instance()->connection) {
            if (func_num_args() == 0 && false != DB::instance()->connection->is_connected()) {
                return true;
            }
        }
        if (func_num_args() > 0) {
            $connect_string = func_get_arg(0);
            $db_user = func_get_arg(1);
            $db_pass = func_get_arg(2);
        } else {
            /* We use the config.php variables */
            $connect_string = Config::get('db_connection')->connection_string;
            $db_user = Config::get('db_connection')->username;
            $db_pass = Config::get('db_connection')->password;
        }
        DB::instance()->connection = DatabaseConnection::ConnectionFactory($connect_string);
        if (null != DB::instance()->connection) {
            return DB::instance()->connection->connect($connect_string, $db_user, $db_pass);
        } else {
            // do some error handling here. The connect string does not have a corresponding DB connection object
            print _t('Panic! No database connection class appears to be found for the connection string specified. Please check config.php');
        }
    }