cakephp 停止自动加载模型/表
我有一个名为“Object”的模型,它加载“Objects”表
我有一个控制器“TestObjectController”,它加载对象模型
<?php
class TestObjectController extends AppController
{
var $name = "TestObject";
function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow('*');
}
function index()
{
$this->autoRender = false;
}
function showall()
{
$this->autoRender = false;
$this->loadModel("Object");
}
}
但是当我实际运行控制器“http://localhost:8002/TestObject”时,它给了我这个错误“缺少数据库表”
$___dataForView = array(
"model" => "TestObject",
"table" => "test_objects",
.....
我猜测它试图加载模型“TestObject”和表“test_object”
是否有办法阻止它从自动加载模型/表
这是我的模型
class Objects extends AppModel {
var $useTable = false;
var $name = 'Object';
}
I have a model named 'Object' which loads the 'Objects' table
I have a controller 'TestObjectController' which loads the Object model
<?php
class TestObjectController extends AppController
{
var $name = "TestObject";
function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow('*');
}
function index()
{
$this->autoRender = false;
}
function showall()
{
$this->autoRender = false;
$this->loadModel("Object");
}
}
But when i actually run the controller 'http://localhost:8002/TestObject' it gives me this error 'Missing Database Table'
$___dataForView = array(
"model" => "TestObject",
"table" => "test_objects",
.....
Im guessing its trying to load the model 'TestObject' and the table 'test_object'
is there a way to stop it from autoloading the model/table
This is my model
class Objects extends AppModel {
var $useTable = false;
var $name = 'Object';
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,只需在控制器中使用此代码即可:
$uses 告诉控制器此处没有要加载的表。
Yes, just use this code at your controller:
$uses tell the controller here there is no table to be loaded.