Welcome Guest, Not a member yet? Register   Sign In
How to move data out of a model and into a controller
#1

[eluser]Unknown[/eluser]
I am new to CodeIgniter but so far am excited to use the framework more.

I have a model which is called getUsers shown as follows:

Code:
function getUsers(){
        $query = $this->db->query("SELECT * FROM users");
}

This will return fields like user_id, username,activation, expiration. This to my understanding will be returned into result()

How do I take that data and bring it over to a controller function which will then take that data and put it in a table?

Any help understanding how this would work would be well appreciated. Further after that I will probably need help moving that into a view and getting the table formatted.
#2

[eluser]InsiteFX[/eluser]
Code:
function getUsers()
{
    $query = $this->db->query("SELECT * FROM users");
}

function get_user()
{
    $query = $this->db->get('users');

    if ($query->num_rows() > 0)
    {
        return $query->row_array();
    }

    return FALSE;
}

// Controller
function index()
{
    $data = array();

    $data['users'] = $this->model_name->get_user();
}




Theme © iAndrew 2016 - Forum software by © MyBB