2013-10-24 40 views
0

我有2個由Pods CMS創建的自定義內容類型:戰鬥和事件。在戰鬥內容類型中有事件的關係字段。我將如何通過特定事件ID從數據庫中選擇所有戰鬥?我試着手動查詢豆莢關係表,但那給了我不正確的結果。如何使用關係字段查詢Pods CMS?

回答

3
$fights = pods('fights'); 

$params = array(
    'where' => 'event.id = 3' 
); 

$fights->find($params); 

// loop through a while($fights->fetch()) and use $fights->field() to get the values of each field 

應該這樣做,但你會想看看您的特定內容類型情況下event.id的「查找」的文件可能不是你想要的(你可能想event.ID)的東西。

http://pods.io/docs/code/pods/

http://pods.io/docs/code/pods/find/

http://pods.io/docs/code/pods/field/

http://pods.io/docs/code/pods/display/

+0

謝謝,但我得到以下錯誤:'未知列「,其中clause'' –

+0

它的工作原理 'event.id'!我打電話給事件pod的名稱,而不是我的戰鬥pod - dumb哈哈事件字段的名稱。非常感謝! –