Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Can't delete ORM object
  • I have an class Model_Child which I made with Fuel's scaffolding. It works well, but when I try to delete it from a function in another class, the record remains in the database. Here's what that function looks like (sort of; function and class names renamed to protect the innocent): public function cool_function_bro($phone) {
    $parent = Mode_Parent::find_by_phone($phone);
    $children = $parent->get_children(); // custom function, not part of ORM foreach ($children as $child) {
    try {
    Model_Child::banaphone_call(array('phone' => $phone'));
    } catch (Exception $e) {
    Log::error(''omg");
    } $child->delete();
    } $parent->delete();
    } When this is ran, the children records are all deleted from the database successfully, but the parent record remains. I did not explicitly define a parent/child relation in either model definition or their respective tables, so I figured this wouldn't be a cascading deletion issue. Is there something I'm missing?
  • The function is being called in a form post, not sure how to get the profiler to show it; Oddly enough as soon as I checked on the results in the database, the record was removed as designed. Not sure what happened but it's working now.
  • If $parent is an ORM model object, I don't see why that shouldn't work. Enable the profiler, enable db profiling, and see what SQL is generated. The DELETE should be there...

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion