路线:
$routes->connect('/textos',['controller' => 'Administracion', 'action' => 'textos']);
控制器:
class AdministracionController extends AppController {
public function textos() {
$this->set('textos', $this->Textos->find('all'));
}
}
模型---> TextosTable
错误:在布尔文件上调用成员函数find() /srv/www/cake-arbol/src/Controller/AdministracionController.php行: 20
第20行:$this->set('textos', $this->Textos->find('all'));
什么问题?名称表是Textos
答案 0 :(得分:1)
问题出在第$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'));
}
}