src/Core/LTIX.php
public static function getConnection() {
        global $PDOX, $CFG;

        if ( isset($PDOX) && is_object($PDOX) && get_class($PDOX) == 'Tsugi\Util\PDOX' ) {
            return $PDOX;
        }

        if ( defined('PDO_WILL_CATCH') ) {
            $PDOX = new \Tsugi\Util\PDOX($CFG->pdo, $CFG->dbuser, $CFG->dbpass);
            $PDOX->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        } else {
            try {
                $PDOX = new \Tsugi\Util\PDOX($CFG->pdo, $CFG->dbuser, $CFG->dbpass);
                $PDOX->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
            } catch(\PDOException $ex){
                error_log("DB connection: ".$ex->getMessage());
                die('Failure connecting to the database, see error log'); // with error_log
            }
        }
        if ( isset($CFG->slow_query) ) $PDOX->slow_query = $CFG->slow_query;
        return $PDOX;
    }
public static function getConnection() {
        global $PDOX, $CFG;

        if ( isset($PDOX) && is_object($PDOX) && get_class($PDOX) == 'Tsugi\Util\PDOX' ) {
            return $PDOX;
        }

        if ( defined('PDO_WILL_CATCH') ) {
            $PDOX = new \Tsugi\Util\PDOX($CFG->pdo, $CFG->dbuser, $CFG->dbpass);
            $PDOX->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        } else {
            try {
                $PDOX = new \Tsugi\Util\PDOX($CFG->pdo, $CFG->dbuser, $CFG->dbpass);
                $PDOX->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
            } catch(\PDOException $ex){
                error_log("DB connection: ".$ex->getMessage());
                die('Failure connecting to the database, see error log'); // with error_log
            }
        }
        if ( isset($CFG->slow_query) ) $PDOX->slow_query = $CFG->slow_query;
        return $PDOX;
    }
public static function getConnection ( ) { global $ PDOX , $ CFG ; if ( isset ( $ PDOX ) && is_object ( $ PDOX ) && get_class ( $ PDOX ) == 'Tsugi\Util\PDOX' ) { return $ PDOX ; } if ( defined ( 'PDO_WILL_CATCH' ) ) { $ PDOX = new \ Tsugi \ Util \ PDOX ( $ CFG -> pdo , $ CFG -> dbuser , $ CFG -> dbpass ) ; $ PDOX -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; } else { try { $ PDOX = new \ Tsugi \ Util \ PDOX ( $ CFG -> pdo , $ CFG -> dbuser , $ CFG -> dbpass ) ; $ PDOX -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; } catch ( \ PDOException $ ex ) { error_log ( "DB connection: " . $ ex -> getMessage ( ) ) ; die ( 'Failure connecting to the database, see error log' ) ; // with error_log } } if ( isset ( $ CFG -> slow_query ) ) $ PDOX -> slow_query = $ CFG -> slow_query ; return $ PDOX ; }
Get a singleton global connection or set it up if not already set up.
Get a singleton global connection or set it up if not already set up .