public function execute($bindings = array(), $useMaster = false)
{
static $retries = 0;
$debug = null;
if ($useMaster) {
$sth =& self::$msth;
$connectionLabel = self::$mConnectionLabel;
} else {
$sth =& $this->sth;
$connectionLabel = $this->connectionLabel;
}
$qStartTime = round(microtime(true), 3);
if ($sth->execute($bindings)) {
$result = $sth->rowCount();
// Check if we need to run an explain for debugging
if ($this->debug > 0) {
$dbh = $useMaster ? self::$mdbh : $this->dbh;
$debug = $this->explainQuery($this->lastQuery, $bindings, $dbh);
}
if ($retries > 0) {
$retries = 0;
}
} else {
$this->logErrorInfo($sth, $connectionLabel);
// Check for dropped connection
if (in_array($this->errorCode, self::$reconnect_on_error) && $retries == 0) {
$retries++;
$this->connect($useMaster, true);
$result = $this->execute($bindings, $useMaster);
} else {
$debug = $this->errorMsg;
$result = -1;
}
}
$qTime = round(microtime(true), 3) - $qStartTime;
$this->updateProfiling($this->lastQuery, $bindings, $qTime, $result, $connectionLabel, $debug);
return $result;
}