Reputation: 733
$this->select("unm")->from("user")->where(array("age"=>20))->result();
not working, even any query including where
.
Not able to use, result()
, row()
etc.
$rowSet=$this->select("unm")->from("user")->where(array("age"=>20));
$rowSet->result();
also not working
Fatal error: Call to undefined method CI_DB_mysql_driver::result() in C:\xampp\htdocs\ci\application\models\testModel.php on line 24
Upvotes: 0
Views: 712
Reputation: 251
Try this:
$where_array = array("age"=>20);
$result = $this->db->select('unm')
->from()
->where($where_array)
->get()->result();
print_r($result); gives you output in the following form
array([0]=>stdobj(),[1]=>stdobj().....)
Upvotes: 0
Reputation: 5506
Why don't you use a function like this?
public function getDataByID($id) {
$this->db->select ( '*' );
$this->db->from ( 'item' );
$this->db->where ( 'id', $id );
$query = $this->db->get ();
$row = $query->first_row ();
return $row;
}
Upvotes: 0