Basecoat\DB::rawQuery PHP Метод

rawQuery() публичный Метод

Used by various other functions (i.e. select, update, insert) to run a query/
public rawQuery ( string $query, boolean $useMaster = false ) : integer
$query string SQL query to run
$useMaster boolean set to TRUE to use the master server connection
Результат integer result of running the query (not data)
    public function rawQuery($query, $useMaster = false)
    {
        static $retries = 0;
        if ($this->connect($useMaster) == -1) {
            return -2;
        }
        $debug = null;
        if ($useMaster) {
            $dbh =& self::$mdbh;
            $connectionLabel = self::$mConnectionLabel;
        } else {
            $dbh =& $this->dbh;
            $connectionLabel = $this->connectionLabel;
        }
        // Save query to last query variable
        $this->lastQuery = $query;
        // Clear error variables
        $this->errorCode = $this->errorMsg = null;
        // Run query and record how long it took
        $qStartTime = round(microtime(true), 3);
        $result = $dbh->exec($query);
        $qTime = round(microtime(true), 3) - $qStartTime;
        if ($result === false) {
            // Log error
            $this->logErrorInfo($dbh, $connectionLabel);
            $debug = $this->errorMsg;
            // Check for dropped connection
            if (in_array($this->errorCode, self::$reconnect_on_error) && $retries == 0) {
                $retries++;
                $this->connect($useMaster, true);
                $result = $this->rawQuery($query, $useMaster);
            } else {
                $result = -1;
            }
        } elseif ($retries > 0) {
            $retries = 0;
        }
        $this->updateProfiling($query, null, $qTime, $result, $connectionLabel, $debug);
        return $result;
    }