我试图通过 $this->Session->read('Player.team_id')... 限制我的分页结果...以便登录用户只能看到他的相关团队成员。
玩家控制器.php
public $paginate = array(
'conditions' => array(
'Player.team_id' => $this->Session->read('Player.0.Team.id')
),
'limit' => 20,
'order' => array('Player.fullname' => 'asc')
);
public function index() {
$this->Paginator->settings = $this->paginate;
$this->Player->recursive = 0;
$this->set('players', $this->Paginator->paginate());
}
这会在查看播放器/索引时导致错误
错误:语法错误,意外的 T_VARIABLE
文件:/home/www/public_html/dev/app/Controller/PlayersController.php
行:21
如果我硬编码下面的“条件”,那么它可以正常工作并且只检索我想要的记录
'conditions' => array('Player.team_id' => 1)
在 Player.php 模型登录操作中,它写入会话变量 Team.id 和 Team.name。
我在我的应用程序(视图和其他模型)中使用了 $this->Session->read else,它工作正常。它似乎不适用于分页组件?