本文整理匯總了PHP中DataAccess::PrepareAndExecuteQuery方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataAccess::PrepareAndExecuteQuery方法的具體用法?PHP DataAccess::PrepareAndExecuteQuery怎麽用?PHP DataAccess::PrepareAndExecuteQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DataAccess
的用法示例。
在下文中一共展示了DataAccess::PrepareAndExecuteQuery方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: PrepareAndExecuteQuery
protected function PrepareAndExecuteQuery($query, $params)
{
$stmt = parent::PrepareAndExecuteQuery($query, $params);
if (!$stmt) {
// If this was a general error, attempt to reconnect and retry the query
// UPDATED: Only care about specific general errors
if ($this->errno == 'HY000' && strpos($this->errorMsg, 'General error: 2006 MySQL server has gone away') !== false) {
echo "Database Error. Waiting 1 minute before attempting to Reconnect.\n";
sleep(60);
echo "Attempting to reconnect...\n";
$this->conn = null;
$this->connect($this->host, $this->user, $this->pass, $this->dbname);
if (!$this->hasError()) {
return parent::PrepareAndExecuteQuery($query, $params);
}
echo "Reconnect Failed\n";
return false;
}
}
return $stmt;
}