Advertisement
Guest User

Untitled

a guest
May 31st, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Per 0.54 KB | None | 0 0
  1.     public function add_rating() {
  2.         $rating = (int) $this->uri->segment(3);
  3.         $resource_id = (int) $this->uri->segment(4);
  4.         if((is_numeric($rating)) && ($rating > 0) && ($rating <= 5)) {
  5.             $res = Doctrine::getTable('Resource')->find($resource_id);       
  6.             $ratings[] = json_decode($res->ratings);
  7. /**use either **/
  8. $result=array_push($ratings,$rating);
  9. /**** OR ***/
  10. $ratings[]=$rating;
  11.             $ratings[] = array_push($rating);
  12.             $res->ratings = json_encode($ratings[]);
  13.             $res->save();
  14.         }
  15.         redirect('/home/show/' . $resource_id);
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement