controller - 控制器不工作
问题描述
路线:
$routes->connect('/textos',['controller' => 'Administracion', 'action' => 'textos']);
控制器:
class AdministracionController extends AppController {
public function textos() {
$this->set('textos', $this->Textos->find('all'));
}
}
模型 ---> TextosTable
错误:调用布尔文件 /srv/www/cake-arbol/src/Controller/AdministracionController.php 上的成员函数 find() 行:20
第 20 行:$this->set('textos', $this->Textos->find('all'));
什么问题?名称表是 Textos
解决方案
问题在于线路$this->Textos->find('all')
您必须在使用之前加载模型 Textos,
use Cake\ORM\TableRegistry;
class AdministracionController extends AppController {
public function textos() {
$textos = TableRegistry::get('Textos');
$this->set('textos', $textos->find('all'));
}
}
推荐阅读
- sapui5 - 翻译无法正确显示非 ASCII 字符
- php - 如何以可折叠的方式显示产品波段和模型
- angular - 如何从数组值中删除小数点值?
- java - 尝试使用 Microsoft Graph Java SDK 从共享 Outlook 日历中获取空闲/忙碌时段时出现错误 401
- raspberry-pi - 如何在树莓派上使用 omxh264enc 将图像传送到 gstreamer?
- python - 如何在kivy中将标签制作为按钮
- python - 吉普错误!堆栈错误:找不到 Python 可执行文件“C:\Users\Admin\Anaconda3\python.EXE”,您可以设置 PYTHON 环境变量
- c# - 如何使用 .net 核心实体框架迁移更新表(而不是重新创建它们)
- protocol-buffers - 向重复消息添加必填字段的问题
- c# - 是否有任何选项可以使用 MODBUS 协议更改我的设备从站 ID?