컨트롤러 :CakePHP는 - 쿼리는 모델 함수의 이름입니다
<?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**
어떤 아이디어가 발생할 수 있습니까? 은 $ name 변수는 컨트롤러의 이름이 아닌 이름 컨트롤러가 사용하는 모델입니다
테이블 비디오를 제거하면 "오류 : 모델 비디오의 데이터베이스 테이블 비디오를 찾을 수 없습니다."오류가 발생합니다. –