我想获取数据库中的行,其中:
“l_area”是表格列
“寄售”是表格
并且限制“l_area”等于“area”变量中存储的值。
我的代码如下所示。即使l_area不等于area,它也只输出所有选定的项目。
function get_all()
{
$area = $this->session->userdata('area');
$this->db->select('l_area','d_area','description','dom','tom'); // the select statement
$this->db->where('l_area' == $area);
$q = $this->db->get('consignment'); // the table
}
最佳答案
试试这个
public function get_all()
{
$area = $this->session->userdata('area');
$this->db->select('*'); // the select statement
$this->db->where('l_area',$area);
$query = $this->db->get('consignment'); // the table
$result = $query->result_array();
print_r($result);
}
关于php - 无法使用 PHP 从数据库获取正确的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36575754/