codeigniter哪里结果不起作用

$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

You didn't executed the query. Try with

$rowSet=$this->select("unm")
->from("user")
->where(array("age"=>20));
$rowSet = $this->db->get();   // this was missing
$query->result();

For Reference

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;
}

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().....)