我正在尝试显示来自table games_reviews的数据,但我从桌面游戏中获取数据,下面是我正在使用的控制器
class GamesReviewsController extends AppController {
var $uses = array('Game', 'GamesVideo', 'games_reviews', 'GamesVideosType', 'GamesRewiewTypes','GamesGenre','User');
public function view() {
//$this->layout = 'pages';
$this->set('columns', 1);
$url = $this->params['game_url'];
$game = $this->Game->findByUrl($url);
//render not found
$videos = Set::combine($game['GamesVideo'], '{n}.id', '{n}', '{n}.position');
if (!empty($game['Game']['amazon_iframe'])) {
$this->set('xtraDiv', array('Buy Game' => array('type' => 'iframe', 'content' => $game['Game']['amazon_iframe'])));
}
$this->set('game', $game);
$this->set('videos', $videos);
}
}
答案 0 :(得分:2)
首先,删除$ uses数组,这不是必需的。
您可能还希望对模型使用Containable
行为。
无论如何,在控制器中,你的代码看起来像这样:
$conditions = array('url' => $url);
$gamesReviews = $this->GamesReview->find('first', compact('conditions'));
我建议你花些时间重新阅读CakePHP Cookbook,理解它会有很大的帮助。