PHP SQLSERVER database project every few days interface cannot access!
-
Thursday, July 19, 2012 10:36 AMPHP 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();
All Replies
-
Monday, July 23, 2012 7:34 AManyone help?
-
Monday, July 30, 2012 2:49 PM
What is your PHP version? What version of the PHP driver are you using? What is your configuration? What version of SQL Server Native Access Client are you using? What version of SQL Server are you using? Can you connect to the SQL Server instance outside of PHP?
Cheers,
Jonathan
This posting is provided 'AS IS' with no warranties, and confers no rights.
- Marked As Answer by Jonathan GuerinMicrosoft Employee Saturday, August 04, 2012 1:14 PM
-
Wednesday, August 01, 2012 12:41 PM
Hi yaphets,
We cannot help you unless you provide more information :)
I'm marking this as answered since there was no reply from the customer.
Thanks,
Jonathan
This posting is provided 'AS IS' with no warranties, and confers no rights.
- Edited by Jonathan GuerinMicrosoft Employee Saturday, August 04, 2012 1:14 PM

