PHP SQLSERVER database project every few days interface cannot access, access interface error 502 Bad Gateway.
The start is a database connection interface can not access, a static page cannot be visited, then http://127.0.0.1:8089/status cannot access. To view the Apache display open.
Then restart the Apache still cannot access, but can be visited after Server restart. about two or three days, also cannot access.
Made several tests found that when there is a procedure frequently invoked when accessing a database will soon appear on this problem
Server operating system is windows2003
Database connection using PDO, the code is as follows:
class dbUtil{
private $dbh;
function __construct() {
$this->dbh = new PDO ( DB_DSN, DB_USERNAME, DB_PASSWORD, array (PDO::SQLSRV_ATTR_DIRECT_QUERY => true, "CharacterSet" => PDO::SQLSRV_ENCODING_SYSTEM,PDO::ATTR_TIMEOUT =>3) );
}
function __destruct() {
$this->dbh=null;
}
function queryAgent() {
$md5key=null;
$password = null;
$balance = null;
$ipflag = null;
$ip = null;
$trustflag = null;
$channel = null;
$ret = null;
$sql="{call Query_Agent(?,?,?,?,?,?,?,?,?)}";
$stmt = $this->dbh->prepare($sql);
$stmt->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM);
$stmt->bindParam(1,$agentId,PDO::PARAM_STR);
$stmt->bindParam(2,$md5key,PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,50);
$stmt->bindParam(3,$password,PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,40);
$stmt->bindParam(4,$balance,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,10);
$stmt->bindParam(5,$ipflag,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,10);
$stmt->bindParam(6,$ip,PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,320);
$stmt->bindParam(7,$trustflag,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,10);
$stmt->bindParam(8,$channel,PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,50);
$stmt->bindParam(9,$ret,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,10);
if ($stmt->execute ()) {
return ;
} else {
$error = $stmt->errorInfo ();
Logger::getLogger('mail')->error("queryAgent($agentId)".$error[2]);
}
}
}
Call mode:
$dbUtil = new dbUtil();
$dbUtil->queryAgent();
The start is a database connection interface can not access, a static page cannot be visited, then http://127.0.0.1:8089/status cannot access. To view the Apache display open.
Then restart the Apache still cannot access, but can be visited after Server restart. about two or three days, also cannot access.
Made several tests found that when there is a procedure frequently invoked when accessing a database will soon appear on this problem
Server operating system is windows2003
Database connection using PDO, the code is as follows:
class dbUtil{
private $dbh;
function __construct() {
$this->dbh = new PDO ( DB_DSN, DB_USERNAME, DB_PASSWORD, array (PDO::SQLSRV_ATTR_DIRECT_QUERY => true, "CharacterSet" => PDO::SQLSRV_ENCODING_SYSTEM,PDO::ATTR_TIMEOUT =>3) );
}
function __destruct() {
$this->dbh=null;
}
function queryAgent() {
$md5key=null;
$password = null;
$balance = null;
$ipflag = null;
$ip = null;
$trustflag = null;
$channel = null;
$ret = null;
$sql="{call Query_Agent(?,?,?,?,?,?,?,?,?)}";
$stmt = $this->dbh->prepare($sql);
$stmt->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM);
$stmt->bindParam(1,$agentId,PDO::PARAM_STR);
$stmt->bindParam(2,$md5key,PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,50);
$stmt->bindParam(3,$password,PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,40);
$stmt->bindParam(4,$balance,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,10);
$stmt->bindParam(5,$ipflag,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,10);
$stmt->bindParam(6,$ip,PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,320);
$stmt->bindParam(7,$trustflag,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,10);
$stmt->bindParam(8,$channel,PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT,50);
$stmt->bindParam(9,$ret,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,10);
if ($stmt->execute ()) {
return ;
} else {
$error = $stmt->errorInfo ();
Logger::getLogger('mail')->error("queryAgent($agentId)".$error[2]);
}
}
}
Call mode:
$dbUtil = new dbUtil();
$dbUtil->queryAgent();