i am trying to check if an id in the database already exists and if it does not then only insert that id and not the other ones that exist
I have tried to do a where sta
You have a logic issue with your code that you need to fix.
In your code, you save the result from your query as $q = $this->db->get('testing')
,
and $q
will always evaluate to true regardless of the number of rows your return.
You need to check the number of rows using $query->num_rows() > 0
and then the rest
of you code will behave as you expect.
For more details, see: http://ellislab.com/codeigniter/user-guide/database/results.html