Welcome Guest, Not a member yet? Register   Sign In
How to run Transactions in controller?

I need to use transactions in my controller. My controller method is given below. This is not working and should not be as far as I understand. So, what could be the solution? Again, is it good practice to use transactions in the controller?

Thank you in advance.

PHP Code:
public function add_payment(){
$this->request->getMethod() != 'post') return redirect()->back();
$this->validate('addOrderPayment')) session()->setFlashdata('error'$this->validator->listErrors());
$oid $this->request->getPost('oid');
$this->request->getPost('odrTkn') === md5(session('token').$oid)){
$order = (new ODR(['gid'=> esc($oid)]))->getOrder();
$data = [
'amount'=> $this->request->getPost('amount')
$db = \Config\Database::connect(); 
            if (
$db->transStatus() === FALSE){
session()->setFlashdata('error''Something went wrong!!');
session()->setFlashdata('success''Payment added successfully!!');
session()->setFlashdata('error''Invalid request!!');

Quote:The output is always the same:
Payment added successfully!!

Thank you in advance.
"Who thinks in code"
Perfectly describes who I am

Messages In This Thread
How to run Transactions in controller? - by webdevron - 04-02-2021, 05:21 AM

Theme © iAndrew 2016 - Forum software by © MyBB