<?php
class VideosController extends ForumAppController {
/**
* Controller Name
* @access public
* @var string
*/
public $name = 'Videos';
public function index() {
$videos = $this->Video->getVideos();
$this->set('videos', $videos);
}
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('*');
if (isset($this->params['admin'])) {
$this->Toolbar->verifyAdmin();
$this->layout = 'admin';
}
$this->Security->validatePost = false;
$this->set('menuTab', 'videos');
}
}
?>
型號:
<?php
class Video extends ForumAppModel {
public $name = 'Video';
function getVideos() {
$vids = $this->find('all', array (
'order' => array('Video.id DESC')
));
return $vids;
}
}
?>
我得到一個錯誤:
Notice (8): Undefined property: VideosController::$Video [CORE/plugins/forum/controllers/videos_controller.php, line 13]
如果我做
$this->loadModel('video');
我得到一個錯誤:
Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'getVideos' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 549]
**Query: getVideos**
任何想法可能會導致什麼呢?
如果我刪除表格視頻,我收到一個錯誤「錯誤:找不到模型視頻的數據庫表視頻。」 – 2011-06-13 05:22:17