I'm getting a very strange database error when a CodeIgniter application I'm working with attempts a particular UPDATE operation.
The Active Record call is:
$this->db->update('eval_events',
array('eval_event_totalscore'=>$result['average_score'],
'eval_event_average_totalscore=>$result['average_score']),
array('eval_event_id'=>$eval_event_id));
And the reported error is:
Error Number: 1054
Unknown column 'id' in 'where clause'
UPDATE `eval_events` SET `eval_event_totalscore` = '40.0000', `eval_event_average_totalscore`
= '40.0000' WHERE `id` = '581' AND `id` = '581' AND `id` = '581' AND `id` = '581' AND `id` =
'581' AND `id` = '581' AND `id` = '581' AND `id` = '581' AND `id` = '581' AND `id` = '581' AND
`id` = '581' AND `id` = '581' AND `id` = '581' AND `id` = '581' AND `id` = '581' AND `id` = '581'
AND `eval_event_id` = '565'
Huh? Where the heck are all those extra conjuncts involving `id` coming from?
Clearly I'm not passing them, and my reading of CI_active_record.php
has given me no clues.
Three additional pieces of information that may be relevant:
- This failure is only happening on my development machine, as far as I can tell. The query seems to be fine on the production machine.
- If I comment out this call to
update()
, the following call toupdate()
gets corrupted in exactly the same way. - The value '581' is significant in the overall context of the operation that these updates are part of, but it's a key in a different table (and anyway, it's bound to a column named `pid`, not `id`).
It feels like the Active Record code has cached that `id` = '581', and something is causing it to cough the contents of that cache out into my UPDATE statement at this point.
I'll admit that I don't understand what Active Record's start_cache()
/stop_cache()
/flush_cache()
methods are really supposed to be good for -- but it shouldn't matter, because grep -r
tells me that there's no call to start_cache()
anywhere in the application's codebase.
Just for grins I tried putting a call to $this->db->flush_cache()
immediately before the failing update()
call, but it didn't change anything.
I have no idea where to look next to try to figure this out.
Any ideas? Anyone?