Welcome Guest, Not a member yet? Register   Sign In
How to write this query by active record
#1

[eluser]FutureKing[/eluser]
I want to write the following query using active record.

UPDATE `app_term_taxonomy` SET count=count+1 WHERE `tx_id` = '24';

This didn't worked for me.
Code:
$data = array(
               'count' => 'count+1',              
            );
            $this->db->where('tx_id', $tx_id);
            $this->db->update('term_taxonomy', $data);
Please help.
#2

[eluser]breizik[/eluser]
Hi,

the method $this->db->set should do the trick:

Code:
$this->db->set('count', 'count+1', false); // I think the last param false is needed to avoid quotation problems
$this->db->where('tx_id', $tx_id);
$this->db->update('term_taxonomy');
#3

[eluser]FutureKing[/eluser]
thanks it worked for me.




Theme © iAndrew 2016 - Forum software by © MyBB