src/Budkit/Datastore/Model/Entity.php
final private function getObjectCountQuery($properties, $vtable = '?property_values', $objectId = NULL, $objectType = NULL, $objectURI = NULL)
    {

        //Join Query
        $query = "SELECT DISTINCT o.object_id as total_objects";
        $hasProperties = FALSE;
        if (!empty($properties)):
            //Loop through the attributes you need
            $i = 0;
            $count = \sizeof($properties);
            //echo $count;
            foreach ($properties as $alias => $attribute):
                //For count queries, there is no need to have added properties.
                //We will only add does we need in the having clause, which is executed after grouping..
                if (in_array($attribute, $this->listLookUpConditionProperties)):
                    if ($i + 1 < $count):
                        $query .= ",";
                        $i++;
                    endif;
                    $alias = (is_int($alias)) ? $attribute : $alias;
                    $query .= "\nMAX(IF(p.property_name = '{$attribute}', v.value_data, null)) AS {$alias}";
                    $hasProperties = TRUE;
                endif;
            endforeach;

            //The data Joins
            $query .= "\nFROM {$vtable} v";
            $query .= ($hasProperties) ? "\nLEFT JOIN ?properties p ON p.property_id = v.property_id" : NULL;
            $query .= "\nLEFT JOIN ?objects o ON o.object_id=v.object_id";
        else:
            $query .= "\nFROM ?objects o";
        endif;

        static::$withConditions = false;
        if (!empty($objectId) || !empty($objectURI) || !empty($objectType)):
            $query .= "\nWHERE";
            if (!empty($objectType)):
                $query .= "\to.object_type='{$objectType}'";
                static::$withConditions = TRUE;
            endif;
            if (!empty($objectURI)):
                $query .= (static::$withConditions) ? "\t AND" : "";
                $query .= "\to.object_uri='{$objectURI}'";
                static::$withConditions = TRUE;
            endif;
            if (!empty($objectId)):
                $query .= (static::$withConditions) ? "\t AND \t" : "";
                $query .= "\to.object_id='{$objectId}'";
                static::$withConditions = TRUE;
            endif;
        endif;

        return $query;
    }
final private function getObjectCountQuery($properties, $vtable = '?property_values', $objectId = NULL, $objectType = NULL, $objectURI = NULL)
    {

        //Join Query
        $query = "SELECT DISTINCT o.object_id as total_objects";
        $hasProperties = FALSE;
        if (!empty($properties)):
            //Loop through the attributes you need
            $i = 0;
            $count = \sizeof($properties);
            //echo $count;
            foreach ($properties as $alias => $attribute):
                //For count queries, there is no need to have added properties.
                //We will only add does we need in the having clause, which is executed after grouping..
                if (in_array($attribute, $this->listLookUpConditionProperties)):
                    if ($i + 1 < $count):
                        $query .= ",";
                        $i++;
                    endif;
                    $alias = (is_int($alias)) ? $attribute : $alias;
                    $query .= "\nMAX(IF(p.property_name = '{$attribute}', v.value_data, null)) AS {$alias}";
                    $hasProperties = TRUE;
                endif;
            endforeach;

            //The data Joins
            $query .= "\nFROM {$vtable} v";
            $query .= ($hasProperties) ? "\nLEFT JOIN ?properties p ON p.property_id = v.property_id" : NULL;
            $query .= "\nLEFT JOIN ?objects o ON o.object_id=v.object_id";
        else:
            $query .= "\nFROM ?objects o";
        endif;

        static::$withConditions = false;
        if (!empty($objectId) || !empty($objectURI) || !empty($objectType)):
            $query .= "\nWHERE";
            if (!empty($objectType)):
                $query .= "\to.object_type='{$objectType}'";
                static::$withConditions = TRUE;
            endif;
            if (!empty($objectURI)):
                $query .= (static::$withConditions) ? "\t AND" : "";
                $query .= "\to.object_uri='{$objectURI}'";
                static::$withConditions = TRUE;
            endif;
            if (!empty($objectId)):
                $query .= (static::$withConditions) ? "\t AND \t" : "";
                $query .= "\to.object_id='{$objectId}'";
                static::$withConditions = TRUE;
            endif;
        endif;

        return $query;
    }
final private function getObjectCountQuery ( $ properties , $ vtable = '?property_values' , $ objectId = NULL , $ objectType = NULL , $ objectURI = NULL ) { //Join Query $ query = "SELECT DISTINCT o.object_id as total_objects" ; $ hasProperties = FALSE ; if ( ! empty ( $ properties ) ) : //Loop through the attributes you need $ i = 0 ; $ count = \ sizeof ( $ properties ) ; //echo $count; foreach ( $ properties as $ alias => $ attribute ) : //For count queries, there is no need to have added properties. //We will only add does we need in the having clause, which is executed after grouping.. if ( in_array ( $ attribute , $ this -> listLookUpConditionProperties ) ) : if ( $ i + 1 < $ count ) : $ query .= "," ; $ i ++ ; endif ; $ alias = ( is_int ( $ alias ) ) ? $ attribute : $ alias ; $ query .= "\nMAX(IF(p.property_name = '{$attribute}', v.value_data, null)) AS {$alias}" ; $ hasProperties = TRUE ; endif ; endforeach ; //The data Joins $ query .= "\nFROM {$vtable} v" ; $ query .= ( $ hasProperties ) ? "\nLEFT JOIN ?properties p ON p.property_id = v.property_id" : NULL ; $ query .= "\nLEFT JOIN ?objects o ON o.object_id=v.object_id" ; else : $ query .= "\nFROM ?objects o" ; endif ; static :: $ withConditions = false ; if ( ! empty ( $ objectId ) || ! empty ( $ objectURI ) || ! empty ( $ objectType ) ) : $ query .= "\nWHERE" ; if ( ! empty ( $ objectType ) ) : $ query .= "\to.object_type='{$objectType}'" ; static :: $ withConditions = TRUE ; endif ; if ( ! empty ( $ objectURI ) ) : $ query .= ( static :: $ withConditions ) ? "\t AND" : "" ; $ query .= "\to.object_uri='{$objectURI}'" ; static :: $ withConditions = TRUE ; endif ; if ( ! empty ( $ objectId ) ) : $ query .= ( static :: $ withConditions ) ? "\t AND \t" : "" ; $ query .= "\to.object_id='{$objectId}'" ; static :: $ withConditions = TRUE ; endif ; endif ; return $ query ; }
Get the final count

@param type $properties
@param type $vtable
@param type $objectId
@param type $objectType
@param type $objectURI
@return type
Get the final count