Welcome Guest, Not a member yet? Register   Sign In
Call to undefined method App\Models\[...]::transStart
#1

My model function is given bellow:

PHP Code:
class Product extends Model
{

    protected $table            'products';
    protected $primaryKey      'product_ID';
    protected $returnType      'object';
    protected $useSoftDeletes  false;
    protected $allowedFields    = ['....'];


    public function saveProduct$new ){
        $val = [];
        if( $new ){
            $val['product_AID']    AID;
            $val['product_GPID']    $this->GPID();
            $val['product_by']      session('user41BApp'.AID);
        }else{
            $info['updated']        time();
        }

        $val['product_title']  esc($this->request->getPost('pName'));
        $val['product_slug']    planeText(esc($this->request->getPost('pName')));
        $val['product_price']  esc($this->request->getPost('pPrice'));
        $val['product_data']    json_encode($data);
        $val['product_info']    json_encode($info);

        $this->transStart();
        $this->save($val);
        $this->saveCat();
        $this->transComplete();

        return ($this->transStatus() === FALSE) ? FALSE : [$val['product_GPID'], $this->request->getPost('cat')];

    }




There is a strange problem.
PHP Code:
model->saveProduct(true); // This is working fine 

PHP Code:
model->saveProduct(false); // This is not working. Showing error:
//Call to undefined method App\Models\Product::transStart 
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply
#2

(This post was last modified: 11-25-2020, 06:24 AM by neoneeco.)

1) Have you tested without this method? (commenting it)

2) It may seem obvious, is this method well implemented ? the code doesn't show it, with the closing class brace.
Reply
#3

PHP Code:
$this->db->transStart();
$this->save($val);
$this->saveCat();
$this->db->transComplete(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(This post was last modified: 11-29-2020, 02:18 PM by webdevron.)

(11-25-2020, 06:22 AM)neoneeco Wrote: 1) Have you tested without this method? (commenting it)

2) It may seem obvious, is this method well implemented? the code doesn't show it, with the closing class brace.

Thank you for your response.
1. Without transection, both method are doing as expected.
Code:
model->saveProduct(true); // Saving product
model->saveProduct(false); // Updating product

With transection only the update product "model->saveProduct(false);" showing the error.

2. This method is a part of a large class. Everything is doing well except the update method.

(11-25-2020, 03:43 PM)InsiteFX Wrote:
PHP Code:
$this->db->transStart();
$this->save($val);
$this->saveCat();
$this->db->transComplete(); 

I am not using Query Builder. Using inherited Codeigniter model instead. Again those method are not working just for
PHP Code:
model->saveProduct(false); 
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply
#5

PHP Code:
$info['updated']        time(); 

Why is this line using the variable $info and not $val (like the rest) ?
Reply
#6

(11-29-2020, 11:34 PM)ojmichael Wrote:
PHP Code:
$info['updated']        time(); 

Why is this line using the variable $info and not $val (like the rest) ?

This is using in the last line where assigning the value:
PHP Code:
$val['product_info']    = json_encode($info); 
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply
#7

I would check the model code, because an update requires that an id field be passed to it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB