2011-10-27 159 views
1

我使用pod創建項目,我想根據它們之間的關係來篩選整個pod。Pod查找記錄關係

例如,我有2個關係從挑:「好」或「壞」

$pods_name = "attitude"; 
//get the specific pod object: 
$thePod = new Pod($pods_name); 
$thePod->findRecords(-1, "attitude.mood = Good"); 
//mood is the label of the relationship you can choose from (has 
//the options between good or bad) 

這裏的問題是,它返回有好有壞的物品。 我無法看到它們在數據庫中是如何鏈接的,是否有更具體的方式來調用它來查找「Good」下列出的項目的記錄?

回答

3

findRecords使用MySQL查詢,你需要把你的好文本放入引號中。 http://podscms.org/codex/findrecords/

您可能正在尋找使用此代碼:雖然我建議使用到$ params方法

$thePod->findRecords('t.name', -1, 'attitude.mood = "Good"'); 

$thePod->findRecords(array('orderby' => 't.name', 'limit' => -1, 'where' => 'attitude.mood = "Good"')); 

而且

此外,在遵循使用的文檔,在動態地將某些內容放入findRecords(用戶輸入)之前,確保在將它放入findRecords之前運行esc_sql($ value)