我正在尝试显示来自桌面游戏评论的数据,但我却从桌面游戏获取数据,下面是我正在使用的 Controller
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);
}
}
最佳答案
首先,删除 $uses 数组,这不是必需的。
您可能还希望对模型使用Containable
行为。
无论如何,在 Controller 中,您的代码将如下所示:
$conditions = array('url' => $url);
$gamesReviews = $this->GamesReview->find('first', compact('conditions'));
我建议您花时间重新阅读 CakePHP Cookbook,理解它会有很大帮助。
关于php - CakePHP 不显示右表中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7918101/