cakephp:有没有办法从$this获得关系->;会话->;读(';验证';);?

cakephp:有没有办法从$this获得关系->;会话->;读(';验证';);?,php,mysql,cakephp,Php,Mysql,Cakephp,生成以下数组: $user = $this->Session->read('Auth'); 我希望它能产生相同的结果,但所有的连接/关系。。。就像这样 array( 'User' => array( 'id' => '2', 'email' => 'info@trinoweb.com', 'username' => 'trino', 'created' => '2012-10-1

生成以下数组:

$user = $this->Session->read('Auth'); 
我希望它能产生相同的结果,但所有的连接/关系。。。就像这样

array(
    'User' => array(
        'id' => '2',
        'email' => 'info@trinoweb.com',
        'username' => 'trino',
        'created' => '2012-10-11 12:41:52',
        'modified' => '2012-10-11 12:41:52',
        'last_online' => null,
        'main_image' => null,
        'address' => null
    )
)

提前感谢。

不,除非在填充身份验证密钥时将其写入其中。这是一个会话变量,不是模型的动态查找

您基本上需要修改登录方法来查找这些关系,然后填充会话数据

请记住,这将是静态数据。如果更改关系,则该关系不会反映在此数组中。发生这种情况时,您需要更新此数组,然后它会变得混乱。

从Cake 2.2+(可能是2.3+,我不记得了)开始,AuthComponent支持
包含
键。尽管如此,正如您所提到的,它只会在用户登录时获取数据,不会自动更新。
array(
    'User' => array(
        'password' => '*****',
        'id' => '128',
        'email' => '12312@asdas.com',
        'username' => 'teresa',
        'created' => '2012-10-11 12:41:52',
        'modified' => '2012-10-11 12:41:52',
        'last_online' => null,
        'main_image' => null,
        'address' => null
    ),
    'Inbox' => array(),
    'Sender' => array(),
    'Upload' => array()
)