Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

[SOLVED] Something to delete all records...

posted by jmtucu 7 years ago

There's a method to delete several records from a table? Something like deleteAll() from CakePHP.

Actually I'm doing

$delete = $db->execute('DELETE FROM foo WHERE bar = %i', $id);

But I don't want to use SQL to do that nor create objets for each record and call ->delete();

Thanks in advanced!

You can build a recordset and then use the call() method to call delete on each record. This is likely less efficient than the above solution, however, it would also incorporate any additional overloaded logic you might have, etc. If you're using active record pattern for other areas and you rely heavily on the added business logic of the domain model then it's the better solution even if less performant in my opinion.

fRecordSet::build('Foo', array('bar=' => $id))->call('delete');
posted by mattsah 7 years ago

Yes, I'm using a fRecordSet for everything so I'll do that! :)

Thanks a lot for your help msahagian!

posted by jmtucu 7 years ago