Rab Ko
Rab Ko

Reputation: 163

how to solve active record $this->db->insert() to achieve an ‘INSERT IGNORE INTO’ statement?

how to solve active record $this->db->insert() to achieve an INSERT IGNORE INTO statement?

I have googled it long time, but failed to find solution

Upvotes: 4

Views: 97

Answers (1)

webGautam
webGautam

Reputation: 565

This is my working script! try this

$inserting_data=array('user_id'=>$user_id,
         'user_name'=>$user_name,
         'id'=>$product_id,
         'cost'=>$click_cost,
         'price'=>$current_winner_amount,
         'auction_price'=>$new_value,          
         'date'=>$this->general->get_local_time('time'),
         'type'=>'A');

$insert_query = $this->db->insert_string('mytbl', $inserting_data);
$insert_query = str_replace('INSERT INTO', 'INSERT IGNORE INTO', $insert_query);  
$this->db->query($insert_query);

Upvotes: 2

Related Questions