Пример #1
0
 /**
  *  tell how many records match $where_criteria in $table
  *  
  *  @param  MingoTable  $table    
  *  @param  MingoCriteria $where_criteria   
  *  @return integer the count   
  */
 public function getCount(MingoTable $table, MingoCriteria $where_criteria = null)
 {
     // canary...
     $this->assure($table);
     $ret_int = 0;
     $itable = $this->normalizeTable($table);
     if (!empty($where_criteria)) {
         $where_criteria->normalizeFields($table);
     }
     //if
     $iwhere_criteria = $this->normalizeCriteria($table, $where_criteria);
     try {
         $ret_int = $this->_getCount($itable, $iwhere_criteria);
         if ($this->hasDebug()) {
             if (!is_int($ret_int)) {
                 throw new UnexpectedValueException(sprintf('_%s() expected to return type: integer, got: %s', __FUNCTION__, gettype($ret_int)));
             }
             //if
         }
         //if
     } catch (Exception $e) {
         if ($this->handleException($e, $table)) {
             $ret_int = $this->getCount($table, $where_criteria);
         }
         //if
     }
     //try/catch
     return $ret_int;
 }