2

I have two objects Puzzle and the PuzzleAnswer. In PuzzleAnswer I have field "puzzle Pointer<Puzzle>" which equal to field "objectId" in Puzzle. How can I query answers by pointer field "puzzle"? This code work well with all field except "puzzle".

$query = new ParseQuery("PuzzleAnswer");
$query->equalTo("Puzzle", "kBT3M6YpvY");
$result = $query->find();

print "<pre>";
var_dump($result);
exit;

result:

array(0) {

}

Thank.

2
  • i haven't used Parse but, as i checked documentation now, yout equalTo method receives ParseObject so can you try this; $puzzle = new OarseObject('kBT3M6YpvY'); $query->equalTo('Puzzle', $puzzle); Commented Jul 27, 2015 at 10:29
  • Thanks for your reply. I checked out, but it didn't help. The fact that it works for other fields, the problem is only with the field puzzle which is "Pointer" Commented Jul 27, 2015 at 10:45

1 Answer 1

2

You are searching for a pointer field with a string. It requires you to search with a Parse Object.

Either create a query for the pointer fields object:

$puzzle = new ParseQuery('Puzzle');

$puzzle->equalTo('objectId', $puzzleId);

$first = $puzzle->first();

Or by bypassing this and passing it an object we create

$query->equalTo("Puzzle", ['__type' => "Pointer", 'className'=> "Puzzle", 'objectId' => $id]);

$result = $query->find();

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.