Fixed: DB Error #1064
This was driving me nuts, the db errors are generated when a staff member checks off a ticket on the main tickets screen and then clicks the delete button and then refreshes the page. When the information is posted to the server again it attempts to delete tickets, however there are none selected. If you make the following change to the delete() function in include\class.ticket.php the errors will no-longer occur.
OLD:
function delete(){
if(db_query('DELETE FROM '.TICKET_TABLE.' WHERE ticket_id='.$this->getId()) && db_affected_rows()):
db_query('DELETE FROM '.TICKET_MESSAGE_TABLE.' WHERE ticket_id='.db_input($this->getId()));
db_query('DELETE FROM '.TICKET_RESPONSE_TABLE.' WHERE ticket_id='.db_input($this->getId()));
db_query('DELETE FROM '.TICKET_NOTE_TABLE.' WHERE ticket_id='.db_input($this->getId()));
$this->deleteAttachments();
return TRUE;
endif;
return FALSE;
}
NEW:
function delete(){
if($this->getId())
{
if(db_query('DELETE FROM '.TICKET_TABLE.' WHERE ticket_id='.$this->getId()) && db_affected_rows()):
db_query('DELETE FROM '.TICKET_MESSAGE_TABLE.' WHERE ticket_id='.db_input($this->getId()));
db_query('DELETE FROM '.TICKET_RESPONSE_TABLE.' WHERE ticket_id='.db_input($this->getId()));
db_query('DELETE FROM '.TICKET_NOTE_TABLE.' WHERE ticket_id='.db_input($this->getId()));
$this->deleteAttachments();
return TRUE;
endif;
}
return FALSE;
}