解析 - PHP SDK无法加载记录

时间:2014-09-13 15:23:23

标签: php parse-platform

我使用parse.com说明测试了安装并且它有效(记录已添加到表中)。现在我正在尝试检索表中的信息(2条记录),而我所拥有的只是一个没有错误的空白页面。

以下是代码:

<?php
require 'vendor/autoload.php';

use Parse\ParseClient;
use Parse\ParseObject;

ParseClient::initialize('djdksjdkks', 'jdksjdksjdksd', 'jdksjdjsdjskdsjdjsdks');

?>

然后在页面后面我希望显示的代码:

<?php
                        $query = new ParseQuery("Donations");
                        //$query->equalTo("playerName", "Dan Stemkoski");
                        $results = $query->find();

                        //echo "Successfully retrieved " . count($results) . " scores.");
                        for ($i = 0; $i < count($results); $i++) { 
                            $object = $results[$i];
                            echo $object->getObjectId() . ' - ' . $object->get('fullname'));
                         }
                      ?>

请帮忙......我读过如果语法有误,PHP会加载白屏。

2 个答案:

答案 0 :(得分:2)

我认为您错过了代码中的use Parse\ParseQuery;

答案 1 :(得分:0)

试试这个

$query = new ParseQuery("Donations");
$results = $query->find();

foreach ( $results as $result ) {
    // echo user Usernames
    echo $result->getObjectId() . ' - ' . $result->get('fullname'));
}

如果您想跟踪错误,请使用try catch

$query = new ParseQuery("Donations");
try {
    $results = $query->find();
    // The objects was retrieved successfully.
} catch (ParseException $ex) {
    // The object was not retrieved successfully.
    // error is a ParseException with an error code and message.
    echo $ex->getMessage(); 
}

foreach ( $results as $result ) {
    // echo user Usernames
    echo $result->getObjectId() . ' - ' . $result->get('fullname'));
}