I have a model with several functions, one of which is supposed to delete some records from several tables that match a specified tag number. However, when I output the MySQL statement to the error log, I see that it's adding some extra parameters, which appears to be taken from another function in the model. It's quite bizarre, and I can't for the life of me figure out what's going on.
Here's the function:
function deleteEquipment() {
$tag = $this->uri->segment(3);
$this->db->where('tag', $tag);
$this->db->delete('equipment');
error_log('mysql: '.$this->db->last_query());
$this->db->where('tag', $tag);
$this->db->delete('process_record');
$this->db->where('tag', $tag);
$this->db->delete('hold');
$this->db->where('tag', $tag);
$this->db->delete('dpo');
error_log('mysql: '.$this->db->last_query());
return;
}
Here is the error log:
WHERE (archived<>'yes' AND (on_lot<>'yes' OR photographs_uploaded<>'yes') AND sold<>'yes') OR (archived<>'yes' AND sold='yes' AND (final_inspection<>'yes' OR jdlink2_registered<>'yes'))
AND `tag` = '40'
[24-Jun-2015 16:10:21 Europe/Berlin] mysql: DELETE FROM `process_record`
WHERE `tag` = '40'
[24-Jun-2015 16:10:21 Europe/Berlin] mysql: DELETE FROM `hold`
WHERE `tag` = '40'
[24-Jun-2015 16:10:21 Europe/Berlin] mysql: DELETE FROM `dpo`
WHERE `tag` = '40'
So, the last three statements look fine, but the first has all of these extra parameters inserted into the statement. The only other place I see these parameters are in a couple of functions in the same model that relate to pagination, e.g.:
function getRowCount() {
// to do: edit this
$q = $this->db->get('equipment');
$where = "(archived<>'yes' AND (on_lot<>'yes' OR photographs_uploaded<>'yes') AND sold<>'yes') OR (archived<>'yes' AND sold='yes' AND (final_inspection<>'yes' OR jdlink2_registered<>'yes'))";
$this->db->where($where);
$rowcount = $q->num_rows();
return $rowcount;
}
I don't have a clue why the parameters from a completely separate function are showing up in the first MySQL statement. Note: There is another function in the same model where the same thing is happening: A few updates to three separate tables where the row matches a tag number. The equipment table query pulls in this weird stuff, but the other queries look fine.
Any idea why this might be happening?