2013-05-28 3 views
0

쿼리 결과를 읽는 방법 : 내가 얻을 echo debug($result);나는 다음과 같은 CakePHP의에서 쿼리를

:

lnguserID = 10; 
$result = $this->Mymodel->find('all', array(
       'fields' => array('Mymodel.intPhoneID'), 
       'conditions' => array('Mymodel.intUserid'=> $lnguserID) 
      )); 

이 같은 결과를 디버깅 할 때

array(
    (int) 0 => array(
     'Mymodel' => array(
      'intPhoneID' => (int) 3975 
     ) 
    ) 
) 

어떻게 결과 배열에서이 id : 3975에 직접 액세스 할 수 있습니까? 예 :

result['Mymodel']['intPhoneID']; 

다른 쿼리에서 사용하고 싶습니다.

+0

hhhhh, 안녕, Working thanks. – OussamaLord

+2

도움을 주시면 [내 대답 수락] (http://meta.stackexchange.com/questions/16721/how-does-accept-rate-work/65088#65088) – Kuf

답변

0
echo $result[0]['Mymodel']['intPhoneID']; 

또한 - echo 디버그 할 필요가 없습니다. 그것은 단지 :

debug($result[0]['Mymodel']['intPhoneID']); 

나는이 컨트롤러에서 가정 - 그렇다면, 당신은 "set'ing '"하여보기에서 액세스 할 수 있습니다 :

// Controller 
$this->set('result', $result); 

// View 
debug($result); 
0

을이 개체 ​​인 경우 -> Mymodel -

array(
    (int) 0 => array(
     'Mymodel' => array(
      'intPhoneID' => (int) 3975 
     ) 
    ) 
) 

당신은 0으로 배열에 접근 할 필요가> intPhoneID, 그래서 사용

result[0]['Mymodel']['intPhoneID'];