Code: Select all
$this->db->query('COMMIT');Code: Select all
$this->db->autocommit(true);Code: Select all
public function publishAction()
{
$id = (int)$this->_getParam('id');
if (!$id) {
$this->illusiveResource();
}
$db = Zend::registry('db');
if($affected = $db->unpublishSite($id)) {
$this->_redirect('/' . $this->controllerName . '/list/');
} else {
// this but always executes
var_dump($affected); // and this is always int(0)
$this->illusiveResource();
}
return true;
}Code: Select all
/**
* Unpublishes a site. Returns whether the site was updated or not.
*
* @param int $siteId
* @return bool
*/
public function _unpublishSite($arg)
{
$q = 'UPDATE Site SET isOnline = 0, wentOffline = NOW() WHERE siteId = '.$arg[0];
$result = $this->qq($q, __FUNCTION__);
return $this->db->affected_rows;
}
/**
* Execute a query and throw an exception if it fails.
*
* @param string $q
* @param string $name the name of the function calling qq(); use __FUNCTION__
* @return mysqli_result
*/
private function qq($q,$name)
{
$status = $this->db->query($q);
$this->queriesExecuted++;
if(!$status) {
$name.= ' generated the following error: '.$this->db->error;
throw new QueryException($name,$this->db->errno,$q);
}
else return $status;
}This problem has only started happening recently, so I've obviously changed something to muck it up but i've no idea.