2015-04-23 63 views
2

我能夠將Parse PHP SDK(版本1.1.2)安裝到我的項目中,並通過成功創建TestObject的快速入門指南。但是,當我試圖查詢對象時,它不返回任何內容。我卡住了,不知道該從哪裏出發。解析PHP SDK不返回查詢結果

use Parse\ParseQuery; 

$query = new ParseQuery('TestObject'); 
$results = $query->find(); 
foreach($results as $result){ 
    echo $result->getObjectId() ." - " $result->get("foo") . "\n"; 
} 

回答

0

你可以試試這樣說:

$myObj= new ParseObject("TestObject"); 

$myObj->set("objIdd", 1234); 
$myObj->set("objName", "My Name"); 

try { 
    $myObj->save(); 
    echo 'New object created with objectId: ' . $myObj->getObjectId(); 
} catch (ParseException $ex) { 
    // Execute any logic that should take place if the save fails. 
    // error is a ParseException object with an error code and message. 
    echo 'Failed to create new object, with error message: ' + $ex->getMessage(); 
} 

//objectId: "XYZABC", objIdd: 1234, objName: "My Name" 

$query = new ParseQuery("TestObject"); 
try { 
    $myObj = $query->get("XYZABC"); 
    // The object was retrieved successfully. 
} catch (ParseException $ex) { 
    // The object was not retrieved successfully. 
    // error is a ParseException with an error code and message. 
} 

看看這個guide

+0

不幸的是,沒有奏效。 我看着ParseQuery.php文件,發現查詢實際上工作正常,因爲我可以在_request方法後輸出一個json數組對象,但當 $ obj - > _ mergeAfterFetchWithSelectedKeys($ row,$ this - > selectedKeys);調用了 。 – djb808

+0

你見過這個Github條目https://github.com/ParsePlatform/parse-php-sdk/blob/master/src/Parse/ParseObject.php – crisu

+0

是的我已經看過它,但無法找到事情發生的地方出錯了。相反,我決定繼續使用REST API獲取json數據並從那裏開始。 – djb808