Welcome Guest, Not a member yet? Register   Sign In
update database with different id
#1

how to do update() deleted_at with different id, i tried it and its not working as it should

Controller Example
    public function RestoreData($id_user)
    {
        $dataUser = [
            'deleted_at' =>  NULL,
        ];
        $this->UserModel->update($id_user, $dataUser);
   
        $dataLogin = [
            'deleted_at' =>  NULL,
        ];
        $this->LoginModel->update($id_user, $dataLogin);
   
        session()->setFlashdata('restore', 'Complete');
        return redirect()->to('Restore');
    }

Database Example
tbl_user
id_user=999 (primary)
deleted_at=2023-07-23 20:31:46

tbl_login
id_login=1 (primary)
id_user=999
deleted_at=2023-07-23 20:31:46

Running Example
/RestoreData/$id_user
($id_user=999)

If I change tbl_login primary_key to id_user it works.

I tried the SQL Query Everything Runs Normal, So How Can the update() Function Update With a Different ID (Not Primary)
Reply


Messages In This Thread
update database with different id - by muh-ramadhan - 07-23-2023, 02:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB