0

I'm currently using the PHP library of Parse SDK and i would like to do an equalTo query on the relation object of a row.

Basically, get all the Lines where relation class LineData column 'status' = 1.

Does anyone have any idea on how to achieve this? I can't find anything in the official docs or a google search.

$query = new ParseQuery("Lines");
$innerQuery = $query->get("LineData")->getQuery()->find();

$innerQuery->equalTo("status", ['__type' => "Pointer", 'className'=> "States", 'objectId' => "XvGh5HkSAw"]);
$results = $innerQuery->find();
return $results;

Any help would be greatly appreciated. Thanks

2 Answers 2

1

use getRelation() on relation columns, not get()

$user = ParseUser::getCurrentUser();
$relation = $user->getRelation("likes");
$query = $relation->getQuery();
$query->equalTo("title", "I'm Hungry");
$postsLiked = $query->find();

http://docs.parseplatform.org/php/guide/#many-to-many-relationships

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

Comments

0

I managed to figure this out myself. Seems we have to do a a query on the child class and then match that query with the parent class.

$innerQuery = new ParseQuery("LineData");
$innerQuery->equalTo("Status", ['__type' => "Pointer", 'className'=> "States", 'objectId' => "XvGh5HkSAw"]);

$query = new ParseQuery("Lines");
$query->matchesQuery("InnerLine", $innerQuery);
$all = $query->find();

Hope it helps anyone.

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.