CodeIgniter Forums
validate if category exist before insert ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: validate if category exist before insert ? (/showthread.php?tid=9235)



validate if category exist before insert ? - El Forum - 06-17-2008

[eluser]Asinox[/eluser]
hi, is me again Big Grin

how i'll know if the category exist before that i save in the table of my DDBB??

Thanks Smile


validate if category exist before insert ? - El Forum - 06-18-2008

[eluser]xwero[/eluser]
You can do a check
Code:
function value_exists($table,$field,$value)
{
     return ($this->db->from($table)->where($field,$value)->count_all_results() == 0)?FALSE:TRUE;
}



validate if category exist before insert ? - El Forum - 07-16-2008

[eluser]Asinox[/eluser]
Thanks Smile