Parse.com request using PHP SDK

I am trying to query Parse.com using the new PHP SDK. I've installed everything I need. I have a problem with the request.

link: [ https://www.parse.com/docs/php_guide#queries]

I 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@me.com");
 $results = $query->find();
 echo "Successfully retrieved " . count($results) . " scores.");

      

Any help would be greatly appreciated! Thank!!!!


SOLVING with help from William George! 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@me.com");
 $results = $query->find();
 echo "Successfully retrieved " . count($results) . " scores.";
 } catch (Exception $e){
    echo $e->getMessage();
 }

      

+3


source to share


1 answer


First, you have a syntax error:

echo "Successfully retrieved " . count($results) . " scores.");

      

Should be

echo "Successfully retrieved " . count($results) . " scores.";

      

Second, you do not include ParseQuery



use Parse\ParseQuery;

      

In addition, the new PHP Parse framework eliminates all exceptions.

Wrap your code in an attempt to catch.

try {
   //parse code
} catch (\Exception $e){
   echo $e->getMessage();
}

      

What is the output now?

+7


source







All Articles