You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php
//fuel/app/classes/controller/child.php
// default function when you use scaffold
public function action_delete($id = null)
{
is_null($id) and Response::redirect('child');
if ($child = Model_Child::find($id)) {
$child->delete();
Session::set_flash('success', 'Deleted child #'.$id);
} else {
Session::set_flash('error', 'Could not delete child #'.$id);
}
Response::redirect('child');
}
Delete And Check Children Data (not reference belongs_to data)
id
parent_id
name
deleted_at
created_at
updated_at
1
1
Child A-1
123456
123456
123456
Edit Delete code(reference belongs_to data)
<?php
//fuel/app/classes/controller/child.php
// default function when you use scaffold
public function action_delete($id = null)
{
・・・・・・・・
if ($child = Model_Child::find($id)) {
echo $child->parent->name; // <---------------- Add this line
$child->delete();
・・・・・・・・
}
Delete And Check Children Data (reference belongs_to data)
id
parent_id
name
deleted_at
created_at
updated_at
1
0
Child A-1
123456
123456
123456
result of parent_id is different when I use lazy loading.