我的作者控制器文件
class AuthorController extends AppController {
public function author_quotes_list($author,$page="null")
{
$perpage=30;
$this->commen();
$author_data=$this->Author->query("select author.*,professions.professions_name from author,professions where author.professions_id=professions.id and author.author_name='$author' and author.status=1 ");
$this->set('author_data',$author_data);
//paging
$count=$quotes_data=$this->Author->query("select count(id) from quotes where author_id=".$author_data[0]['author']['id']." and status=1");
$limit=$this->paging($page,$count,$perpage);
$quotes_data=$this->Author->query("select id,quotes from quotes where author_id=".$author_data[0]['author']['id']." and status=1 limit $limit,$perpage");
//print_r($quotes_data);
$this->set('quotes_data',$quotes_data);
}
public function ratings($q_id)
{
//echo $quotes_id;
$tuser=$this->Author->query("select count(id) from user where status=1");
//print_r($tuser);
if($tuser==NULL)
{
$this->set('tuser',0);
}
else
{
$this->set('tuser',$tuser[0][0]['count(id)']);
}
$vusers=$this->Author->query("select * from totalrate where quoteid=$q_id");
print_r($vusers);
if($vusers==NULL)
{
$this->set('vuser',0);
$this->set('trate',0);
}
else
{
$this->set('vuser',$vusers[0]['totalrate']['totaluser']);
$this->set('trate',$vusers[0]['totalrate']['totalrate']);
}
}
我的 author_quotes_list.ctp 文件
<?php $this->requestAction(array('controller' => 'Author', 'action' => 'ratings/'.$quotes['quotes']['id']));?>
<div class="star_txt">(<?php echo $trate; ?>/5, <?php echo $vuser; ?> votes) from <?php echo $tuser; ?> Users</div>
当我调用作者控制器的评级函数时,调用此函数但未设置 $trate 、 $vuser 和 $tuser 值的值。