这是我的代码:
$ child = $ this-> getDetails($ row ['ParentOf_Id']);
是另一个调用getdetails函数的函数:
function getDetails($ child_id = null,$ limit = 20){
// select all the fields in the children table
$this->db->select(castedColumns($this->children_table, $this->db));
//where the id is the child id
$q = $this->db->get_where($this->children_table, 'id='.$child_id);
//store results array in details
$details = $q->row_array();
然后我得到以下SQL错误:
发生数据库错误 错误号码:
'='附近的语法不正确。
选择CAST(AdditionalNotes AS TEXT)作为AdditionalNotes,CAST(DisabilitiesNotes AS TEXT)作为DisabilitiesNotes,DOB,msrepl_tran_version FROM Children WHERE id =
ID没有附加?为什么呢?
让我疯了,因为,当我回音$ child_id;在将它传递给SQL之前,我得到了孩子ID。
答案 0 :(得分:0)
尝试:
$this->db->select(castedColumns($this->children_table, $this->db));
$q = $this->db->get_where($this->children_table, array('id' => $child_id));
$details = $q->row_array();
答案 1 :(得分:0)
我猜想$ child_id为null,否则会显示在db error查询中。尝试打印$ child_id并查看它是否真的是null,这意味着
$child = $this->getDetails($row['ParentOf_Id']);
$ row ['ParentOf_Id']为空。