Wednesday, January 19, 2022

[FIXED] How to get Return Value to use in Controller

Issue

this is my function in model.php

function add_user($data, $table){
        $this->db->trans_start();
        $insert_id = $this->db->insert($table, $data);
        $this->db->insert_id();
        $this->db->trans_complete();

        return $insert_id;
    }

how to get the value of $insert_id in other function *Sorry for my bad english


Solution

you can do like this in controller

$inserted_id  = $this->Add_user_model->add_user($data, $table);

documentation : https://codeigniter.com/userguide3/general/models.html#id4



Answered By - rahul satone

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.