CodeIgniter Forums
eh don't worry about it - 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: eh don't worry about it (/showthread.php?tid=49360)



eh don't worry about it - El Forum - 02-16-2012

[eluser]pdxbenjamin[/eluser]
I have a few database tables for my users and on occasion the delete will fail because at times not all the tables have data for that user. How do I structure a delete statement to fail gracefully, and not worry about finding a matching row?

* I'm in the process of cleaning up the validator so fields can't be empty, but for now I need to clean up the old data. *

I just run a bunch of these in a function...
Quote:$did = $this->input->post('did');
$this->db->where('did', $did);
$this->db->delete('address');

$this->db->where('did', $did);
$this->db->delete('work_histor');



Thanks


eh don't worry about it - El Forum - 02-16-2012

[eluser]solid9[/eluser]
check if the table is not empty.
before deleting...