Welcome Guest, Not a member yet? Register   Sign In
Incrementing a counter in the database
#1

[eluser]CI Simon[/eluser]
I'm having a problem with a function that needs to update a counter for the records found.

It's working fine on my local development machine but fails to update on the live server.

Can anyone give me an idea of where i've gone wrong.

Thanks,
Simon

Code:
function getAdvertiserEmailList ($region_id, $category_id)
    {
        $this->db->select('*');
        $this->db->from('fq_company');
        $this->db->join('fq_company_category', 'company_id = fq_company.id');
        $this->db->where('region_id', $region_id);
        $this->db->where('category_id', $category_id);
        $query = $this->db->get();

        $advertiser_id_array = array();
        $output = "";
        
        //Check if any companys are found
        if ($query->num_rows() > 0) {

            foreach ($query->result() as $advertisers) {
                
                    $advertiser_id_array[] = $advertisers->id;
    
                    $output .= $advertisers->company_email;
                    $output .= ", ";
                }
            
            $output = substr ($output, 0, -2);
            
            // Update company_count for emailed companies
            $this->db->set('company_count', 'company_count + 1', FALSE);
            $this->db->where_in('id', $advertiser_id_array);
            $query = $this->db->update('fq_company');
        
        }
        
        return $output;
    }


Messages In This Thread
Incrementing a counter in the database - by El Forum - 08-31-2008, 01:28 PM
Incrementing a counter in the database - by El Forum - 09-03-2008, 12:38 AM
Incrementing a counter in the database - by El Forum - 09-03-2008, 01:03 AM
Incrementing a counter in the database - by El Forum - 09-03-2008, 02:41 AM
Incrementing a counter in the database - by El Forum - 09-06-2008, 09:20 AM
Incrementing a counter in the database - by El Forum - 09-07-2008, 10:05 AM
Incrementing a counter in the database - by El Forum - 09-08-2008, 12:47 AM
Incrementing a counter in the database - by El Forum - 09-08-2008, 01:44 AM
Incrementing a counter in the database - by El Forum - 09-08-2008, 02:59 AM
Incrementing a counter in the database - by El Forum - 05-29-2009, 05:59 AM
Incrementing a counter in the database - by El Forum - 05-29-2009, 06:55 AM
Incrementing a counter in the database - by El Forum - 05-29-2009, 07:10 AM
Incrementing a counter in the database - by El Forum - 05-29-2009, 07:16 AM
Incrementing a counter in the database - by El Forum - 05-29-2009, 07:21 AM
Incrementing a counter in the database - by El Forum - 05-29-2009, 07:28 AM
Incrementing a counter in the database - by El Forum - 05-29-2009, 07:32 AM
Incrementing a counter in the database - by El Forum - 05-29-2009, 07:35 AM
Incrementing a counter in the database - by El Forum - 05-30-2009, 11:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB