source/Application/Model/Rating.php
public function getRatingCount($sObjectId, $sType, $aIncludedObjectsIds = null)
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        $sQuerySnipet = " AND `oxobjectid` = " . $oDb->quote($sObjectId);
        if (is_array($aIncludedObjectsIds) && count($aIncludedObjectsIds) > 0) {
            $sQuerySnipet = " AND ( `oxobjectid` = " . $oDb->quote($sObjectId) . " OR `oxobjectid` in ('" . implode("', '", $aIncludedObjectsIds) . "') )";
        }

        $sSelect = "
            SELECT
                COUNT(*)
            FROM `oxreviews`
            WHERE `oxrating` > 0
                AND `oxtype` = " . $oDb->quote($sType)
                   . $sQuerySnipet . "
            LIMIT 1";

        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
        $masterDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();
        $iCount = $masterDb->getOne($sSelect);

        return $iCount;
    }
public function getRatingCount($sObjectId, $sType, $aIncludedObjectsIds = null)
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        $sQuerySnipet = " AND `oxobjectid` = " . $oDb->quote($sObjectId);
        if (is_array($aIncludedObjectsIds) && count($aIncludedObjectsIds) > 0) {
            $sQuerySnipet = " AND ( `oxobjectid` = " . $oDb->quote($sObjectId) . " OR `oxobjectid` in ('" . implode("', '", $aIncludedObjectsIds) . "') )";
        }

        $sSelect = "
            SELECT
                COUNT(*)
            FROM `oxreviews`
            WHERE `oxrating` > 0
                AND `oxtype` = " . $oDb->quote($sType)
                   . $sQuerySnipet . "
            LIMIT 1";

        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
        $masterDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();
        $iCount = $masterDb->getOne($sSelect);

        return $iCount;
    }
public function getRatingCount ( $ sObjectId , $ sType , $ aIncludedObjectsIds = null ) { $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sQuerySnipet = " AND `oxobjectid` = " . $ oDb -> quote ( $ sObjectId ) ; if ( is_array ( $ aIncludedObjectsIds ) && count ( $ aIncludedObjectsIds ) > 0 ) { $ sQuerySnipet = " AND ( `oxobjectid` = " . $ oDb -> quote ( $ sObjectId ) . " OR `oxobjectid` in ('" . implode ( "', '" , $ aIncludedObjectsIds ) . "') )" ; } $ sSelect = "
            SELECT
                COUNT(*)
            FROM `oxreviews`
            WHERE `oxrating` > 0
                AND `oxtype` = " . $ oDb -> quote ( $ sType ) . $ sQuerySnipet . "
            LIMIT 1" ; // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804). $ masterDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getMaster ( ) ; $ iCount = $ masterDb -> getOne ( $ sSelect ) ; return $ iCount ; }
calculates and return objects rating count

@param string $sObjectId           object id
@param string $sType               object type
@param array  $aIncludedObjectsIds array of ids

@return integer
calculates and return objects rating count