如何在我的表中获取具有特定 ID 的特定列 -CodeIgniter


how to get a specific coloumn with a specific id in my table -CodeIgniter

我正在尝试使用 CodeIgniter 在我的表中获取具有特定 id 的特定列我尝试了以下方法:

$query = $this->db->get_where('mytable', array('id' => $id));

但它给出了整行;我只需要那行 id =$id 和一个列名称"name"。

谢谢

您需要

设置CodeIgniter要选择的列。 http://ellislab.com/codeigniter/user-guide/database/active_record.html#select

$query = $this->db->select('name')->where('id',$id)->get('my_table');
$result = $query->row();

row()仅返回结果集中的一行。第一个