简体   繁体   English

使用PHP SDK查询Parse.com

[英]Querying Parse.com using PHP SDK

I am trying to query Parse.com using the new PHP SDK. 我正在尝试使用新的PHP SDK查询Parse.com。 I have installed everything necessary. 我安装了所有必要的东西。 I am having a problem querying though. 我在查询时遇到了问题。

link:[ https://www.parse.com/docs/php_guide#queries] 链接:[ 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@me.com");
 $results = $query->find();
 echo "Successfully retrieved " . count($results) . " scores.");

Any help would be greatly appreciated! 任何帮助将不胜感激! Thank you!!!! 谢谢!!!!


SOLVED using William George's help! 使用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();
 }

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 其次,你不包括ParseQuery

use Parse\ParseQuery;

Also, the new PHP Parse framework throws exceptions all over the place. 此外,新的PHP Parse框架会在所有地方抛出异常。

Wrap your code in a try catch. 将代码包装在try catch中。

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

What does the output say now? 输出现在说什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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