I am trying to run an update for a specific row of a table and increase by one the content of a column each time the update runs. However at certain times the query doesn't run and it does not produce an exception either. Does anyone know why this might be happening? I have tried the following:
$intVersion = $this->intVersion + 1;
$strSql=<<<EOT
UPDATE $this->strQueryTable SET version = '$intVersion' WHERE id = $this->id;
EOT;
$blnQueryOk = mysql_query ( $strSql );
$intVersion = $this->intVersion + 1;
$strSql =<<<EOT
UPDATE $this->strQueryTable SET version = $intVersion WHERE id = $this->id;
EOT;
$blnQueryOk = mysql_query ( $strSql );
$strSql =<<<EOT
UPDATE $this->strQueryTable SET version = version + 1 WHERE id = $this->id;
EOT;
$blnQueryOk = mysql_query ( $strSql );
and under all cases:
if (!$blnQueryOk) {
throw new Exception(mysql_error ());
return false;
}
All of them fail to update some times without producing an exception.
mysql_connect()
call, verify that the db connection resource has really been created, and in case of a false return value, start throwing an exception. mysql_error()
not producing anything is when you have multiple database connections open in the same process. To avoid this:
mysql_query()
and mysql_error()
calls, also start passing the db connection resource as a parameter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.