2017-11-06 9 views
0

私は2テーブルtblAlbumとtblProductionを持って、アルバムはtblProductionとの関係を持っています。 (album_title、album_id、制作(種類のParseRelation)、...)どのようにクエリを解析するphp sdk ParseRelationのすべてのキーを取得しますか?

私はアルバムを取得するためのクエリを書くには、すべてのプロダクションキーが含まれていますか?このよう
(ALBUM_TITLE、album_id、production_name、production_title、...)

*私は任意の助けのための解析PHP SDK

感謝を使用しています!

+0

誰でも助けることができますか? – sony

答えて

0

私はあなたがポインタまたは関係としてproductionセットアップを持っているかどうかわからないんだけど、私はあなたのためにここの両方について詳しく説明します。

ポインタ(1-1)のようにクエリを調整する必要があります。 関係(1対多)として

$query = new ParseQuery('Album'); 

// include the nested object under 'production' 
$query->includeKey('production'); 

// get albums with Production set under 'production' 
$albums = $query->find(); 

あなたは、関連するすべてのproductionオブジェクトを取得するための別のクエリを作成する必要があります。

$relation = $albums->getRelation('production'); // can add Production as the class name as 2nd arg if you have issues 
$relationQuery = $relation->getQuery(); 

// get all Production objects 
$productions = $relationQuery->find(); 

あなたが継続的にあなたがダウンし、約2クエリにあなたのオーバーヘッドを減らすことができ、各Albumため、この関係クエリを作っている場合。 Productionにポインタを追加して、親のAlbumに戻り、ParseQuery::orQueriesを使用してすべてという便利なクエリにクエリを結合します。

// get albums 
$query = new ParseQuery('Album'); 
$albums = $query->find(); 

// get each relation query for each album 
$queries = []; 
foreach($albums as $album) { 
    $relation = $album->getRelation('production', 'Production'); 
    $queries[] = $relation->getQuery(); 
} 

// combine your relation queries 
$query = ParseQuery::orQueries($queries); 

// include the parent 'album' pointer so we can 
// sort which objects belong where 
$query->includeKeys('album'); 

// get these productions 
$productions = $query->find(); 

またmatchesKeyInQueryでいくつかのものを行うことができ、私はそれにいくつかの詳細を取得するdocs上に読みになることをお勧めします。

関連する問題