user2667314
user2667314

Reputation: 33

Model returning null values

I'm a new bee to web development. I need to get data (some columns) from the job table and filter it according to the user name in the session and a status value (status is a TINYINT there for contains 0 and 1).

Here is my model:

public function show_work() {
      $user_name = $this->session->userdata('Name');
      $this->load->database();
      $this->db->select('jbStageID, Description, StartDate, SpecialDetails, EstimateTime, Instrauctions');
      $this->db->where('Name',$user_name);
      $this->db->where('status','0');
      $rset=$this->db->get('job');
      $result=$rset->result_array();
}

Here is my controller:

public function employees()
{
    $this->load->model('show_details');  
    $result= $this->show_details->show_work();
    $data = array();
    $data['inbox'] = $this->show_details->show_work();
    var_dump($result);
    echo "<pre>";
    print_r($data);
    echo "</pre>";
    die();

}

The issue is I don't get values from the database but value null with empty array. The result is like this:

Array(
    [inbox] =>
)

Upvotes: 2

Views: 104

Answers (2)

Lab
Lab

Reputation: 1063

you missed $this->db->from

that means from table in sql query.

Upvotes: 0

Code Lღver
Code Lღver

Reputation: 15603

You need to use the return to return the data as below in the model's last line:

$result=$rset->result_array();
return $result;

Upvotes: 3

Related Questions