English 中文(简体)
Cakephp 1.3:在缩略语中显示用户数据
原标题:Cakephp 1.3: Displaying user data in paginated comments

另一个相当基本的问题 我原谅,但我感到,我同我一样,坐在圈子里,摆脱思想, ha。

我试图建立一个有想象力的评议系统(通过Ajax),这必须能够显示用户的名称、ava等等,从而撰写了特别的评论。 足够简单、正确吗?

不管怎样,所有事情都是很出色的,但迄今为止,我只是找回相应用户信息的途径,而我也找不到任何东西在笔试中有所帮助。

这里,我迄今为止的《座谈法》:

$this->paginate[ Comment ] = array(
     conditions =>array( Entry.id =>$id),
     contain  => array( Entry ,  User =>array( avatar ,  username ) ),
     limit  => 10
);
$comments = $this->paginate( Comment );
$this->set(compact( comments ));

因此,我已经用了软件来获取用户模型的数据。

echo $comment[ User ][ username ];
echo $comment[ User ][ avatar ];

但是,这当然显示用户的信息相当于......美元。

However, I need to get a users info through the foreignkey user_id of the current comment. And at the moment I m at a loss how to do that... Any help would be greatly appreciated. Thanks in advance!

问题回答

如果我不记错的话,我会记得,如果我不正确的话。

 contain  => array( Entry ,  User.avatar,User.username )),

the

奥凯解决了这一问题。

我不得不补充适当的外国。 我的评论模式的关键,即:

var $belongsTo = array(
 Entry  => array( className  =>  Entry ,  foreignKey  =>  page_id ),
 User  => array( className  =>  User ,  foreignKey  =>  user_id ),
);

现在它最终收集了适当的用户信息!





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签