public function checkTransLog($id) { if (!empty($id)) { $transaction = Transaction::find_by_main_id($id); if ($transaction) { //echo "<p><strong class='alert-box alert'>Record cannot be deleted! <br /> History already existing for this record</strong></p>"; return 2; } elseif (!$transaction) { $merole = Cproduct::find_by_mainid($id); if ($merole->delete()) { return 1; } } else { return 3; ///Unexpected Error } } }