dplbf4340 2011-10-27 15:13
浏览 11
已采纳

CakePHP不显示右表中的数据

I am trying to display data from table games_reviews but instead I am getting data from table games, below is the controller I am using

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);



}

}

  • 写回答

1条回答 默认 最新

  • douhan8581 2011-10-27 16:36
    关注

    First, remove the $uses array, this will not be required.

    You will also probably want to use the Containable behavior for your models.

    Anyhow, in the controller, your code would look like this:

    $conditions = array('url' => $url);
    $gamesReviews = $this->GamesReview->find('first', compact('conditions'));
    

    I would suggest you take the time to re-read the CakePHP Cookbook, understanding it will greatly help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?