franklin
franklin

Reputation: 35

what's wrong with my select query in model php codeigniter?

here is my code :

 function getValue($id)
  {
        $this->db->select('value');
        $this->db->where('id',$id);
        $q = $this->db->get('ref_table');
        $data = array_shift($q->result_array());
        $result = $data['value'];
        return $result;
  }

when executed emerge error array conversion to string

Upvotes: 2

Views: 122

Answers (1)

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

Error gives you the answer Array conversion to string

Try this

In model

 public function getValue($id)
  {
        $this->db->select('value');
        $this->db->where('id',$id);
        $q = $this->db->get('ref_table');
        $result = $q->result_array();
        return $result;
  }

In Controller

$data['value'] = $this->Model_name->getValue($id);
$this->load->view('my_view',$data)

Upvotes: 1

Related Questions