Example #1
0
 public function checkRated($object_id, $object_type, $user_id)
 {
     if (!empty($user_id)) {
         $ratingTable = new Book_Model_DbTable_Ratings();
         $select = $ratingTable->select()->where('parent_object_type = ?', $object_type)->where('parent_object_id = ?', $object_id)->where('user_id = ?', $user_id);
         return $ratingTable->fetchRow($select) != NULL;
     }
     return NULL;
 }
Example #2
0
 public function getRatingSum()
 {
     $table = new Book_Model_DbTable_Ratings();
     $ratingSum = $table->select()->from($table->info('name'), new Zend_Db_Expr('SUM(rating)'))->where('parent_object_id = ?', $this->getIdentity())->where('parent_object_type = ?', $this->getType())->query()->fetchColumn(0);
     return $ratingSum;
 }