Welcome Guest, Not a member yet? Register   Sign In
Updating the same Table twice, even thought it should not
#1

[eluser]No0oB[/eluser]
I have been having a weird problem recently.
I have a function, which shall remove old entries from a database table (where saved timestamp is smaller than current timestamp)

Code:
function clearRecruitingQueue()
{
    $this->CI->db->select('`city_id`')->from(TBL_QUEUE_WORKER)->where('`worker_endStamp` <', time());
    $query = $this->CI->db->get();
    foreach ($query->result() as $row)
    {
        $this->CI->db->query('UPDATE '.TBL_CITY.' SET `city_worker` = `city_worker` + 1 WHERE `city_id` = '.$this->CI->db->escape($row->city_id));
        $this->CI->db->delete(TBL_QUEUE_WORKER, array('`city_id`', $row->city_id));
    }
}

However, when there is more than 1 item, it always updates one each time, the loop is run.
When I echo the city_id, it shows different IDs..

What is my mistake?
The queries do change, yet, it updates only one entry

Thanks in advance


Messages In This Thread
Updating the same Table twice, even thought it should not - by El Forum - 02-03-2008, 02:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB