2013-01-19 3 views
1

여러분 중 얼마나 많은 사람들이 parse.com 플랫폼에 익숙한 지 모르지만 웹 사이트에 링크 된 타사 PHP 라이브러리를 활용하고 있으며 몇 가지 문제가 있습니다. .PHP Parse.com 쿼리 오류

링크 : Parse.com PHP Library

내 DB를 조회하려고하지만 내 코드가 정확하지만 오류가 라이브러리에 포함 된 파일 중 하나에서 유래 내가 무엇을 볼 수에서 Notice: Trying to get property of non-object.를 반환 유지합니다. 오류를 던지고있다

function storeInParseDB ($message, $unit) { 

    $parse = new parseQuery($class = 'PushNotifications'); 
    $parse->whereEqualTo('unit', $unit); 
    $result = $parse->find(); 

    echo "RESULT: "; 
    print_r($result); 
} 

코드 : 어떤 도움을 크게 감상 할 수

private function checkResponse($response,$responseCode,$expectedCode){ 
     //TODO: Need to also check for response for a correct result from parse.com 
     if($responseCode != $expectedCode){ 
      $error = json_decode($response); 
      $this->throwError($error->error,$error->code); 
     } 
     else{ 
      //check for empty return 
      if($response == '{}'){ 
       return true; 
      } 
      else{ 
       return json_decode($response); 
      } 
     } 
    } 

여기에 지금까지 내 코드입니다.

+0

오류가있는 줄을 지적 해 주시겠습니까? – Ifthikhan

+0

줄 176은 다음과 같습니다 : $ this-> throwError ($ error-> error, $ error-> code); 어딘가에 json_decode 함수와 관련이 있다고 말한 것을 읽은 것 같습니다. –

+0

https://github.com/apotropaic/parse.com-php-library/issues/30 –

답변

1

https://github.com/apotropaic/parse.com-php-library.git을 복제 한 후 다음 코드를 실행합니다 - readme에 설명 된대로 appid, restkey 및 masterkey가있는 parseConfig.php 파일을 생성했습니다.

문자열 형식의 단일 열 "단위"로 구문 분석 데이터 브라우저에 새 클래스를 만들고 한 행에 unit = test를 추가했습니다.

<?php 

include 'parse.com-php-library/parse.php'; 

function storeInParseDB ($message, $unit) { 
     $parse = new parseQuery('PushNotifications'); 
     $parse->whereEqualTo('unit', $unit); 
     $result = $parse->find(); 

     echo "RESULT: "; 
     print_r($result); 
} 

storeInParseDB('hi', 'test'); 

원하는 출력을 다시 얻을 수 있으므로 원하는대로 parseConfig.php 파일을 올바르게 설정했는지 확인하십시오.

RESULT: stdClass Object 
(
    [results] => Array 
     (
      [0] => stdClass Object 
       (
        [unit] => test 
        [createdAt] => 2013-01-21T14:57:26.613Z 
        [updatedAt] => 2013-01-21T14:57:26.613Z 
        [objectId] => 0uiYuJcRYY 
       ) 

     ) 

) 
+0

MAMP를 사용하여 문제없이 작동하지만, XAMPP를 사용하는 Windows Machine에서 json_decode 함수를 사용하여 문제를 해결합니다. –