AlkantarClanX12

Your IP : 216.73.217.24


Current Path : /www/capitalgmcbuickregina_830/public/wp-content/plugins/wp-cerber/includes/db-warp/
Upload File :
Current File : /www/capitalgmcbuickregina_830/public/wp-content/plugins/wp-cerber/includes/db-warp/db-warp.php

<?php
/*
	Copyright (C) 2025-26 CERBER TECH INC., https://wpcerber.com

    Licensed under the GNU GPL.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/

declare( strict_types=1 );

spl_autoload_register( function ( $class_name ) {
	static $classes = [
		'CRB_Database'        => '/CRB_Database.php',
		'CRB_Query_Builder'   => '/CRB_Query_Builder.php',
		'CRB_Schema_Manager'  => '/CRB_Schema_Manager.php',
		'CRB_Schema_Compiler' => '/CRB_Schema_Compiler.php',
	];

	if ( $file = $classes[ $class_name ] ?? '' ) {
		require_once( __DIR__ . $file );
	}
} );

/**
 * Returns a database connection wrapping the global WordPress mysqli handle.
 *
 * Caches the wrapper in a process-wide static variable. The wrapper holds the
 * mysqli handle captured at first call and intentionally does NOT track later
 * changes to $wpdb->dbh. Call with $rewrap = true to discard the cached wrapper
 * and rebuild it against the current $wpdb->dbh.
 *
 * @param bool $rewrap Discards the cached wrapper and re-wraps the current $wpdb->dbh.
 *
 * @return Revalt<CRB_Database> The connection wrapped in a DTO, or a dependency error.
 */
function warp_get_db( bool $rewrap = false ): Revalt {
	static $db_instance = null;

	if ( $rewrap ) {
		$db_instance = null;
	}

	if ( $db_instance !== null ) {
		$result = new Revalt();
		$result->success( $db_instance );

		return $result;
	}

	global $wpdb;

	// Pragmatic guard: ensure the external dependency is fully initialized
	// and holds a valid mysqli object before passing it to wrap().
	if ( ! isset( $wpdb->dbh ) || ! ( $wpdb->dbh instanceof mysqli ) ) {
		return new Revalt(
			null,
			'db_dependency_error',
			'Global $wpdb->dbh is not initialized or is not a valid mysqli instance.'
		);
	}

	$db_instance = CRB_Database::wrap( $wpdb->dbh );

	$result = new Revalt();
	$result->success( $db_instance );

	return $result;
}

/**
 * Executes a database operation against a guaranteed valid connection.
 *
 * @param Closure(CRB_Database): Revalt $operation The query builder logic to execute.
 *
 * @return Revalt The outcome of the operation, or a connection error.
 */
function warp_run_db( Closure $operation ): Revalt {
	$db_result = warp_get_db();
	if ( $db_result->has_errors() ) {
		return $db_result;
	}

	return $operation( $db_result->get_results() );
}

Home - Capital GMC Buick Regina

No data

Welcome to Capital GMC BUICK – REGINA

Thank you for choosing Capital GMC Buick | Regina, your premier certified Buick and GMC dealership proudly serving drivers in Regina and the surrounding communities. Whether you’re searching for a brand-new Buick or GMC vehicle or a meticulously inspected pre-owned model, we have a diverse selection to match your needs and lifestyle.

Beyond our impressive inventory, we offer a seamless and stress-free financing experience through our well-connected finance centre, where our team of experts is dedicated to securing the best loan or lease options for you, quickly, transparently, and hassle-free.

But our commitment to you doesn’t stop at the sale. Our state-of-the-art service centre is staffed with skilled Buick and GMC technicians who use the latest equipment and genuine OEM parts to keep your vehicle running at its best. From routine maintenance to complex repairs, we’ve got you covered.

Experience top-tier customer service, quality vehicles, and expert care, all in one place. Visit Capital GMC Buick | Regina today or call us at 306-205-8072 with any questions. We’re here to help!

Ask a Question