Pod findRecords 关系

发布于 2024-12-11 20:44:06 字数 422 浏览 0 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑,眼淚并存 2024-12-18 20:44:06

findRecords 使用 MySQL 查询,您需要将 Good 文本放入引号中。

另外,请按照以下位置使用的文档进行操作: http://podscms.org/codex/findrecords/

您可能正在寻找使用此代码:

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

虽然我建议使用 $params 方法:

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

另外,在动态地将某些内容(用户输入)放入 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:

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

Though I suggest using the $params method:

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

Also, before putting something into findRecords dynamically (user-input), be sure to run esc_sql($value) on it before placing it into findRecords

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文