Development

Changeset 9255

You must first sign up to be able to contribute.

Changeset 9255

Show
Ignore:
Timestamp:
05/25/08 23:11:20 (5 years ago)
Author:
gordon
Message:

implement countRatings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfRatingPlugin/trunk/lib/behavior/sfRatingDoctrineTemplate.class.php

    r9254 r9255  
    1212 * @package    sfLucenePlugin 
    1313 * @subpackage Behavior 
    14  * @author     Carl Vondrick <carlv@carlsoft.net> 
     14 * @author     Gordon Franke 
    1515 */ 
    1616class sfRatingDoctrineTemplate extends Doctrine_Template 
     
    2929   * Counts ratings made on given ratable object. 
    3030   *  
    31    * @param  BaseObject  $object 
    3231   * @return int 
    3332   */ 
    34   public function countRatings($object) 
    35   { 
    36     $c = new Criteria(); 
    37     $c->add(sfRatingPeer::RATABLE_ID, sfRatingToolkit::getReferenceKey($object)); 
    38     $c->add(sfRatingPeer::RATABLE_MODEL, get_class($object)); 
    39     return sfRatingPeer::doCount($c); 
     33  public function countRatings() 
     34  { 
     35    $object = $this->getInvoker(); 
     36    return Doctrine_Query::create() 
     37      ->from('sfRating') 
     38      ->where('ratable_id = ? AND ratable_model = ?') 
     39      ->count(array(sfRatingToolkit::getReferenceKey($object), get_class($object))); 
    4040  } 
    4141 
     
    7171   * Gets the object rating details 
    7272   * 
    73    * @author Gordon Franke 
    7473   * @param  boolean     $include_all  Shall we include all available ratings? 
    7574   * @return associative array containing (rating => count)