Welcome Guest, Not a member yet? Register   Sign In
Error Call to a member function update() on array
#1

Hello Everyone,
I have a Controllers :
------------------
<?php

namespace App\Controllers;

use App\Models\TPS_DetailModel;
use App\Models\TPSModel;

class TpsPar extends BaseController {

-------------------------------------------------
Two Models:  TPSModel and TPS_DetailModel.  (Like  tables Order and Order Details).
Structure of the TPS table : {id_tps , name, status } .  TPS_Detail: { id_tps_det , id_par, qty }.
Insert data to TPS Details successfully.
I want to update on table TPS field 'status' with value 1 ,  when insert data to TPS Details successfully.
Data type of the 'status' field is integer.
Below my code in controller:
                    $varTPSModel = new TPSModel();

                    $builder = $varTPSModel->where('id_tps', $id_tps)->first(); 
                   
                    // print_r($builder);    This is Ok. return 1 row data
                    // exit;  
                 
                    $data = [                                       
                             'status' => '1',                                   
                         ];

                   
                    // Update the row in the table TPS
                                 
                    $builder->update($data); 

I get error message, "Error Call to a member function update() on array".
How to fix issue ?
Thank you
Reply
#2

PHP Code:
$builder->where('id'$id);
$builder->update($data); 
What did you Try? What did you Get? What did you Expect?

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

(This post was last modified: 10-16-2023, 01:25 AM by kenjis.)

Read https://codeigniter4.github.io/CodeIgnit...html#first
and https://codeigniter4.github.io/CodeIgnit...tml#update
Reply




Theme © iAndrew 2016 - Forum software by © MyBB