Reputation: 1976
I don't know how many of you are familiar with the parse.com platform, but I am utilizing the third party php library that is linked on their website and I am running into a couple problems.
Link: Parse.com PHP Library
I am trying to query my db but it keeps returning Notice: Trying to get property of non-object.
From what I can see my code is correct but the error originates from one of the files included in the library.
Here is my code thus far:
function storeInParseDB ($message, $unit) {
$parse = new parseQuery($class = 'PushNotifications');
$parse->whereEqualTo('unit', $unit);
$result = $parse->find();
echo "RESULT: ";
print_r($result);
}
Code that is throwing the error:
private function checkResponse($response,$responseCode,$expectedCode){
//TODO: Need to also check for response for a correct result from parse.com
if($responseCode != $expectedCode){
$error = json_decode($response);
$this->throwError($error->error,$error->code);
}
else{
//check for empty return
if($response == '{}'){
return true;
}
else{
return json_decode($response);
}
}
}
Any help would be greatly appreciated.
Upvotes: 1
Views: 2141
Reputation: 3768
I'm running the following code after cloning https://github.com/apotropaic/parse.com-php-library.git - created a parseConfig.php file with appid, restkey and masterkey as decribed in the readme.
I created a new Class in the Parse Data Browser with a single column "unit" of type string and added one row to it, unit = test.
<?php
include 'parse.com-php-library/parse.php';
function storeInParseDB ($message, $unit) {
$parse = new parseQuery('PushNotifications');
$parse->whereEqualTo('unit', $unit);
$result = $parse->find();
echo "RESULT: ";
print_r($result);
}
storeInParseDB('hi', 'test');
As you can see I get the desired output back, make sure you have setup your parseConfig.php file correctly.
RESULT: stdClass Object
(
[results] => Array
(
[0] => stdClass Object
(
[unit] => test
[createdAt] => 2013-01-21T14:57:26.613Z
[updatedAt] => 2013-01-21T14:57:26.613Z
[objectId] => 0uiYuJcRYY
)
)
)
Upvotes: 1