I'm using CodeIgniter and have a case where two tables (projects and tasks) need to be updated with a value right after one another (active column needs to be set to "n"). The code I am using is:
function update($url, $id)
{
$this->db->where('url', $url);
$this->db->update('projects', array('active' => 'n'));
$this->db->where('eventid', $id);
$this->db->update('tasks', array('active' => 'n'));
}
With this code, the projects table gets updated but the tasks table does not. If I comment out $this->db->update('projects', array('active' => 'n'));
then the tasks table gets updated.
I reckon this has something to do with caching but I have tried flush_cache
before the tasks db->update
call but that didn't have any effect.
Can someone explain how consecutive update queries can be executed using CodeIgniter?
WHERE
s, it is strange that you're having issues. Tryecho
ing$this->db->last_query()
after each update andexit
ing to make sure the queries are actually correct. – Wesley Murch