【发布时间】:2018-03-14 15:43:47
【问题描述】:
我的应用程序已经有一些虚拟字段在运行,但是这个让我很头疼。
所以我有实体 SubactivitySlots,代码如下:
protected $_virtual = [
'slots_text',
];
和
protected function _getSlotsText(){
return "test";
}
当我运行查询时:
debug($this->SubactivitySlots->find('all')->first());
它返回以下结构(尝试使用 first 和 toArray()
object(App\Model\Entity\SubactivitySlot) {
'id' => (int) 1,
'name' => 'MAIN',
'description' => '-',
'activity_id' => (int) 1,
'subactivity_min' => (int) 1,
'subactivity_max' => (int) 1,
'position' => (int) 1,
'institution_id' => (int) 1,
'deleted' => (int) 0,
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [
(int) 0 => 'slots_text'
],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'SubactivitySlots'
}
有什么可能出错的线索吗?我花了很多时间试图发现却无法发现。最奇怪的是我在另一个实体上使用虚拟字段并且它正在工作。
谢谢
【问题讨论】:
标签: cakephp entities cakephp-3.4