original_string: public function getByProduct($product_id)
      {
          $result = null;
          $this->hook->attach('rating.get.before', $product_id, $result, $this);
  
          if (isset($result)) {
              return $result;
          }
  
          $sql = 'SELECT rating, votes FROM rating WHERE product_id=?';
          $result = $this->db->fetch($sql, array($product_id));
  
          $this->hook->attach('rating.get.after', $product_id, $result, $this);
          return $result;
      }
code: public function getByProduct($product_id)
      {
          $result = null;
          $this->hook->attach('rating.get.before', $product_id, $result, $this);
  
          if (isset($result)) {
              return $result;
          }
  
          $sql = 'SELECT rating, votes FROM rating WHERE product_id=?';
          $result = $this->db->fetch($sql, array($product_id));
  
          $this->hook->attach('rating.get.after', $product_id, $result, $this);
          return $result;
      }
code_tokens: public function getByProduct ( $ product_id ) { $ result = null ; $ this -> hook -> attach ( 'rating.get.before' , $ product_id , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ sql = 'SELECT rating, votes FROM rating WHERE product_id=?' ; $ result = $ this -> db -> fetch ( $ sql , array ( $ product_id ) ) ; $ this -> hook -> attach ( 'rating.get.after' , $ product_id , $ result , $ this ) ; return $ result ; }
docstring: Returns an array of rating data for a given product
  @param integer $product_id
  @return array
docstring_tokens: Returns an array of rating data for a given product