on_before_delete doesnt work

edited April 2012 in Bug Reports
Hi, I try to delete pictures before i delete data from database table. And I found this code and try to edit to my case but doesnt work i try to debug it but var where is empty. Any solution?

function on_before_delete($where)
{
$id = $this->_determine_key_field_value($where);
$data = $this->find_by_key($id);
$files[] = assets_server_path('sluzby/'.$data->foto, 'images');
$files[] = assets_server_path('sluzby/thumb_'.$data->foto, 'images');
foreach($files as $file)
{
if (file_exists($file))
{
unlink($file);
}
}
}

Comments

  • edited 9:23PM
    problem was with access to array is not object but array, so solved

    function on_before_delete($where)
    {
    $id = $this->_determine_key_field_value($where);
    $data = $this->find_by_key($id);
    $files[] = assets_server_path('sluzby/'.$data['foto'], 'images');
    $files[] = assets_server_path('sluzby/thumb_'.$data['foto'], 'images');
    foreach($files as $file)
    {
    if (file_exists($file))
    {
    @unlink($file);
    }
    }
    }
Sign In or Register to comment.