• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$this->db->insert related problem

[eluser]Aziz Chouhan[/eluser]
hi all
i am working on codeigniter project since few days.
i have worked on all db related functions like select ,delete , update and insert, and these all worked very well.
but now i am facing a problem in db->insert();

this is my code which i written in a model function.
Quote: function update_hit_count($field_name,$field_id)

$data = array( 'field_name' => $field_name , 'field_id' => $field_id, 'hit_count' => '1' );
$this->db->insert('hit_count', $data);


when i called to this function with args as ('teacher',42)
it results 1 row as correct result
and also 3 or 6 rows as bad result with ('teacher',0,1)

i don't know where i m doing mistake

i have also checked


which returns proper query

and also

which returns 1 row affected


can anybody help me on this issue
its really very urgent

1) are you sure update_hit_count($field_name,$field_id) isn't being called more times in your controller that you are not intending/aware of? (i.e., a bug in your code causing a loop or extra function calls you don't really want)

2) can you post the results of $this->db->last_query();

[eluser]Aziz Chouhan[/eluser]
hi buddy
this is the object you want to know
Quote:INSERT INTO `hit_count` (`field_name`, `field_id`, `hit_count`) VALUES ('tutor', '42', '1')


but at the this moment i have manually solved this problem

thanks for reply

According to the code you posted, you're trying to call your update_hit_count() function with an additional parameter that you do not have defined.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.