简体   繁体   中英

Parse PHP SDK doesn't return query result

I was able to install the Parse PHP SDK (version 1.1.2) to my project and got through the quick start guide in successfully creating a TestObject. However, when I tried to query the objects, it returns nothing. I'm stuck and don't know where to go from here.

use Parse\ParseQuery;

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

You could try it this way:

$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.
}

Take a look at this guide .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM