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

[eluser]tonanbarbarian[/eluser]
try the following
Code:
function clearRecruitingQueue()
{
    $this->CI->db->select('`city_id`')->from(TBL_QUEUE_WORKER)->where('`worker_endStamp` <', time());
    $query = $this->CI->db->get();
    $results = $query->result();
    $query->free_result();
    foreach ($results as $row)
    {
        $this->CI->db->simple_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));
    }
}


the $query->result() inside the foreach may be a problem in PHP5 because all objects are created as references. The issue then is that db->query also returns a recordset like the earlier db->get does
There may have been problems whereby after the initial pass through the loop the $query->result() was actually returning the result from the update.

not sure if this really is the problem but it is worth a try


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



Theme © iAndrew 2016 - Forum software by © MyBB