Pod findRecords 关系
我使用 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”下列出的项目的记录?
I create items using pods, I want to filter through the pods depending on what their relationship is.
Eg I have 2 relationships to pick from: "Good" or "Bad"
$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)
The problem with this is that it returns items in both Good and Bad.
I can't see how they're linked in the database, is there a more specific way you have to call it to find the records of only items listed under "Good"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
findRecords 使用 MySQL 查询,您需要将 Good 文本放入引号中。
另外,请按照以下位置使用的文档进行操作: http://podscms.org/codex/findrecords/
您可能正在寻找使用此代码:
虽然我建议使用 $params 方法:
另外,在动态地将某些内容(用户输入)放入 findRecords 之前,请确保在将其放入之前对其运行 esc_sql($value)查找记录
findRecords uses MySQL queries, you need to put your Good text into quotes.
Also, follow the documentation used at: http://podscms.org/codex/findrecords/
You likely are looking to use this code:
Though I suggest using the $params method:
Also, before putting something into findRecords dynamically (user-input), be sure to run esc_sql($value) on it before placing it into findRecords