解析PHP - 查询Relation类

解析PHP  - 查询Relation类

问题描述:

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

我目前正在使用Parse SDK的PHP库,我想对关系对象进行equalTo查询 一排 p>

基本上,获取关系类LineData列'status'= 1的所有行。 p>

有没有人知道如何实现这一点? 我在官方文档或Google搜索中找不到任何内容。 p>

  $ query = new ParseQuery(“Lines”); 
 $ innerQuery = $ query->  get(“LineData”) - > getQuery() - > find(); 
 
 $ innerQuery-> equalTo(“status”,['__ type'=>“Pointer”,'className'=>  ;“States”,“objectId”=>“XvGh5HkSAw”]); 
 $ results = $ innerQuery-> find(); 
return $ results; 
  code>  pre> 
 
  

非常感谢任何帮助。 谢谢 p> div>

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.

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