2012-03-14 3 views
0

내 코드는 다음과 같다 :Codeigniter - SQL 오류입니다. 나를 미치게한다.

$ child = $ this-> getDetails ($ row [ 'ParentOf_Id']); 함수 호출 getdetails 호출하는 다른 기능에

:

기능 getDetails을 ($ child_id = NULL, $ 한계 = 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 오류를 얻을 :

근처의 구문이 잘못되었습니다 '=':

데이터베이스 오류가 오류 번호를 발생했습니다. 식

이드가 추가되지 않는 아이들 DisabilitiesNotes, DOB, msrepl_tran_version 같은 AdditionalNotes, CAST (TEXT DisabilitiesNotes AS) 등

SELECT 캐스팅 (TEXT AS AdditionalNotes)? 왜?

내 말을 믿을 때, 나는 $ child_id를 echo 할 것이기 때문에 견과를 몰고왔다. 나는 자식 ID를 SQL에 전달하기 전에 그것을 얻는다.

답변

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(); 
0

나는 그렇지는 DB 오류 쿼리에 표시 것, $ child_id가 null 추측 것입니다. $ child_id를 인쇄하고

$child = $this->getDetails($row['ParentOf_Id']); 

$ 행 [ 'ParentOf_Id는'] null 인 것을 의미 널이 정말 있는지 확인하십시오.

+0

$ child_id = null이 $ child_id로 변경되었으며 mikhail 솔루션이 트릭을 수행 한 것으로 보입니다. 건배. – bobo2000

관련 문제