CodeIgniter Forums
delete a record without get() - using DataMapper - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: delete a record without get() - using DataMapper (/showthread.php?tid=58114)



delete a record without get() - using DataMapper - El Forum - 05-16-2013

[eluser]cehennem[/eluser]
Hey there,

I wonder why it's not possible to delete a record from a table without necessary of get() them first, in datamapper.

So I treid some llike this but it's not working;

$members = new Members();
$members->where('id', 150)->delete(); // supposed to delete member with id=150


Is there any way to simply delete a record from the table, without selecting it first? If not, I'm going to have to write my own delete function which may look silly Smile


delete a record without get() - using DataMapper - El Forum - 05-17-2013

[eluser]PravinS[/eluser]
http://ellislab.com/codeigniter/user-guide/database/active_record.html#delete


delete a record without get() - using DataMapper - El Forum - 05-17-2013

[eluser]WanWizard[/eluser]
Datamapper is an ORM, not a query builder or generator. You can't delete what you don't have, so you need to get it first.

If you don't want that, @pbs has pointed you to the alternative (what works how you want to).