cakephp错误消息允许的内存大小为134217728字节

时间:2017-08-10 08:15:33

标签: php cakephp

我有功能,它可以提高老师的平均费率,我保存变量$ result的平均值我希望将变量传递给get_teacher_average_rating并打印平均值,但我尝试这样做我有错误

  

函数RatingSchoolsController :: get_teacher_average_rating()的参数太少,0在第35行的/Applications/MAMP/htdocs/classera-core-code/app/Controller/RatingSchoolsController.php中传递,正好是预期的1

public function get_teacher_average_rating($result)
    {
        $this->autoRender = false;
      $this->loadModel('Rating');
        if($this->request->is('get'))
        {
            $author_id = $this->request->query('author_id');//
            $rate = $this->Rating->find('all',array('conditions'=>array('author_id'=> $author_id), 'fields'=> array('AVG(Rating.value) as averageRating'), 'recursive' =>-1));

            $average = $rate[0][0]['averageRating'];
            $result = array('success'=>'1' , 'average' => $average );
        }
        else{
            $result = array('success'=>'0','message'=>'request type is not GET');
        }
        echo json_encode($result);
    }





public function set_teacher_average_rating()
    {
        $this->autoRender = false;
              $this->loadModel('Rating');

                $average = $this->get_teacher_average_rating();
                $rate = $this->Rating->find('all',array('conditions'=>array('author_id'=> $author_id) , 'recursive' =>-1));
                                echo json_encode($average );
}

1 个答案:

答案 0 :(得分:0)

错误消息看起来非常清楚:“函数RatingSchoolsController :: get_teacher_average_rating(),0传递的参数太少”。您没有将参数传递给get_teacher_average_rating,因此它失败了。

您的方法似乎并不需要传入$result的值,因此您应该能够从方法中删除它: -

public function get_teacher_average_rating() {
    ...
}