I am trying to query Parse.com using the new PHP SDK. I have installed everything necessary. I am having a problem querying though.
link:[https://www.parse.com/docs/php_guide#queries]
I have tried using this:
require 'vendor/autoload.php';
use Parse\ParseClient;
use Parse\ParseObject;
ParseClient::initialize('secret1','secret2', 'secret3');
$query = new ParseQuery("TableName");
$query->equalTo("email", "[email protected]");
$results = $query->find();
echo "Successfully retrieved " . count($results) . " scores.");
Any help would be greatly appreciated! Thank you!!!!
SOLVED using William George's help! Here is my updated code:
require 'vendor/autoload.php';
use Parse\ParseClient;
use Parse\ParseObject;
use Parse\ParseQuery;
ParseClient::initialize('secret1','secret2', 'secret3');
try{
$query = new ParseQuery("TableName");
$query->equalTo("email", "[email protected]");
$results = $query->find();
echo "Successfully retrieved " . count($results) . " scores.";
} catch (Exception $e){
echo $e->getMessage();
}
Firstly you have a syntax error:
echo "Successfully retrieved " . count($results) . " scores.");
Should be
echo "Successfully retrieved " . count($results) . " scores.";
Secondly you do not include ParseQuery
use Parse\ParseQuery;
Also, the new PHP Parse framework throws exceptions all over the place.
Wrap your code in a try catch.
try {
//parse code
} catch (\Exception $e){
echo $e->getMessage();
}
What does the output say now?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With