Codeigniter:在控制器中显示查询结果 [英] Codeigniter : displaying query result in controller
本文介绍了Codeigniter:在控制器中显示查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在控制器中显示数据库查询结果,但是我不知道该怎么做。
I am trying to display my db query result in my controller, but I don't know how to do it. could you please show me?
Controller
Controller
function get_name($id){
$this->load->model('mod_names');
$data['records']=$this->mod_names->profile($id);
// I want to display the the query result here
// like this: echo $row ['full_name'];
}
我的模型
function profile($id)
{
$this->db->select('*');
$this->db->from('names');
$this->db->where('id', $id);
$query = $this->db->get();
if ($query->num_rows() > 0)
{ return $query->row_array();
}
else {return NULL;}
}
推荐答案
echo '<pre>';
print_r($data['records']);
或
echo $data['records'][0]['fullname'];
这篇关于Codeigniter:在控制器中显示查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文