Phalcom Transaction Manager getting 500 server error when rollback is triggered
https://drive.google.com/file/d/0B7AtJVATjxPFTDktdFFuRXlFM3c/view?usp=sharing
$request = new Request();
$guid = new Guid();
$transactionManager = new TransactionManager();
$transaction = $transactionManager->get();
if($request->isPost()){
$directoryid = $guid->GUID();
$memberid = $request->getPost('memberid');
$directorytitle = $request->getPost('directorytitle');
$path = $request->getPost('path');
$findfolder = Membersdirectory::findFirst("directorytitle = '".$directorytitle."' AND path = '". $path ."'");
if($findfolder){
$data = array('error' => 'Folder is already exist!', 'statuscode' => 400 );
}
else{
try {
$savefolder = new Membersdirectory();
$savefolder->setTransaction($transaction);
$savefolder->directoryid = $directoryid;
$savefolder->memberid = $memberid;
// $savefolder->directorytitle = $directorytitle;
$savefolder->path = $path;
$savefolder->datecreated = date('Y-m-d H:i:s');
if($savefolder->save()){
$data = array('success' => 'New folder successfully created!', 'statuscode' => 200 );
// $transaction->rollback();
}
else{
$data = array('error' => 'Something went wrong!', 'statuscode' => 400 );
$transaction->rollback();
}
$transaction->commit();
}
catch (Phalcon\Mvc\Model\Transaction\Failed $e) {
echo "Failed, reason: ", $e->getMessage();
}
}
echo json_encode($data);
}