2011-10-27 153 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)