gpt4 book ai didi

model - Joomla 3 模型上的filter_fields

转载 作者:行者123 更新时间:2023-12-02 04:34:30 25 4
gpt4 key购买 nike

我购买了“学习 Joomla!3 扩展开发,第三版”。这本书 super 棒!作为 Joomla 的新手!开发,它对我的​​第一份工作构建新组件有很大帮助。但是,我仍然不明白模型构造函数:

public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'state', 'a.state',
'company', 'a.company',
'image', 'a.image',
'url', 'a.url',
'phone', 'a.phone',
'description', 'a.description',
'ordering', 'a.ordering', 'a.catid'
);
}

parent::__construct($config);
}

“id”和“a.id”、“title”和“a.title”、“phone”和“a.phone”等之间有什么关系?会joomla!自动分配数据库表中的值还是什么?当我将“电话”更改为“电话”时,我无法检索数据。先谢谢了。

最佳答案

我也对此感到困惑。我找到了answer here (quoted below) 。显然,它只是一个允许的字段名称白名单,仅此而已。

The value of this setting is merely a white list of field names that are permitted for usage in queries. So, you can see we’ve got quite a few of the standard fields names. We’ve also added some variants of those names that are query specific, just in case someone else using this model wants to use them. That’s really all there is. When you click on one of the list headings, it sets the ordering column for the list in the request. We know that the populateState method in the model will pick this value up from the request and when it does, it checks it against this white list. If the requested ordering column is not in the white list, it reverts, safely, to the default ordering.

关于model - Joomla 3 模型上的filter_fields,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19587303/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com