Php Codeigniter获取活动记录中的位置
使用codeigniter get_where函数创建查询以获取特定数据时遇到问题。我阅读并理解了手册,并在我的代码中使用了它,但现在当我准备像下面的代码一样从数据库中查询时,它不起作用 型号:Php Codeigniter获取活动记录中的位置,php,codeigniter,Php,Codeigniter,使用codeigniter get_where函数创建查询以获取特定数据时遇到问题。我阅读并理解了手册,并在我的代码中使用了它,但现在当我准备像下面的代码一样从数据库中查询时,它不起作用 型号: public function load_parents () { $query = $this->db->get_where('checklist_items', array(('checklist_id' => $checklist_id) && ('paren
public function load_parents () {
$query = $this->db->get_where('checklist_items', array(('checklist_id' => $checklist_id) && ('parent_id' => $parent_id)));
$result = $query->result_array ();
return $result;
}
错误:
消息:语法错误,意外的“=>”(T_双箭头),应为“”
我知道代码不正确,但是否有其他方法使其运行?使用
$query = $this->db->get_where('checklist_items', array('checklist_id' => $checklist_id, 'parent_id' => $parent_id));
使用以下命令:
<?php
public function load_parents ()
{
$query = $this->db->get_where('checklist_items', array('checklist_id' => $checklist_id, 'parent_id' => $parent_id));
$result = $query->result_array ();
return $result;
}
?>
尝试使用此代码
public function load_parents () {
$query = $this->db->get_where('checklist_items', array('checklist_id' => $checklist_id , 'parent_id' => $parent_id));
$result = $query->result_array ();
return $result;
}
不能在数组中使用&&
<> >将自动考虑<代码>和< /代码> .<
另一种方法是使用where like
public function load_parents () {
$query = $this->db
->where('checklist_id' => $checklist_id)
->where('parent_id' => $parent_id)
->get('checklist_items');
$result = $query->result_array();
return $result;
}
缺少
数组
关键字$checklist\u id)&&('parent\u id'=>$parent\u id)
您所说的关键字是什么意思?