/**
  * Static Qcodo Query method to query for a count of LengthUnit objects.
  * Uses BuildQueryStatment to perform most of the work.
  * @param QQCondition $objConditions any conditions on the query, itself
  * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  * @return integer the count of queried objects as an integer
  */
 public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null)
 {
     // Get the Query Statement
     try {
         $strQuery = LengthUnit::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     // Perform the Query and return the row_count
     $objDbResult = $objQueryBuilder->Database->Query($strQuery);
     // Figure out if the query is using GroupBy
     $blnGrouped = false;
     if ($objOptionalClauses) {
         foreach ($objOptionalClauses as $objClause) {
             if ($objClause instanceof QQGroupBy) {
                 $blnGrouped = true;
                 break;
             }
         }
     }
     if ($blnGrouped) {
         // Groups in this query - return the count of Groups (which is the count of all rows)
         return $objDbResult->CountRows();
     } else {
         // No Groups - return the sql-calculated count(*) value
         $strDbRow = $objDbResult->FetchRow();
         return QType::Cast($strDbRow[0], QType::Integer);
     }
 }