How to ensure that file has been deleted from folder and also related data deleted from database in codeigniter
<p>I am working with codeigniter, i want to delete a file from a folder and also delete related data from database. But how to ensure that either both will be done successfully otherwise none of them will took place.</p>

<p>Following code is my approach towards it, but i am concern about the case like, file deleted successfully but for some reason database operation was unsuccessful. Is there any better approach for this?</p>

<pre><code>if(unlink($path)){
    $this-&gt;admin_model-&gt;delete_data($id,$db);

}
</code></pre>