Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我开始使用 cakePhp,我想知道:
当我进行查询时(例如使用 $this->Product->find(...)),我会收到一个数组,对吗?
然后: - 如果我有一些带有默认值的非数据库字段,我必须为每个产品显示,我该怎么办?
我看到了虚拟字段,但我无法将静态变量放入其中
您可以使用 Anh Pham 提供的另一件事的解决方案,如果它只是设置值以显示它们,则在获得结果后将它们添加到控制器中的数组中:
$result['Model']['desired_field_name'] = $static_field;