function Count()
    {
		if (!$this->CountIsKnown())
		{
			// check the cache
			$cachekey = $this->_sql . " COUNT";
			$this->_totalcount = $this->GetDelayedCache($cachekey);

			// if no cache, go to the db
			if ($this->_totalcount != null)
			{
				$this->_phreezer->Observe("DataSet.Count: skipping count query because cache exists",OBSERVE_DEBUG);
			}
			else
			{
				$this->LockCache($cachekey);

				
				$sql = "";

				// if a custom counter sql query was provided, use that because it should be more efficient
				if ($this->CountSQL)
				{
					$this->_phreezer->Observe("DataSet.Count: using CountSQL to obtain total number of records",OBSERVE_DEBUG);
					$sql = $this->CountSQL;
				}
				else
				{
					$this->_phreezer->Observe("(DataSet.Count: CountSQL was not provided so a counter query will be generated.  Implement GetCustomCountQuery in the reporter class to improve performance.)",OBSERVE_WARN);
					$sql = "select count(1) as counter from (" . $this->_sql . ") tmptable" . rand(1000,9999);
				}

				$rs = $this->_phreezer->DataAdapter->Select($sql);
				$row = $this->_phreezer->DataAdapter->Fetch($rs);
				$this->_phreezer->DataAdapter->Release($rs);
				$this->_totalcount = $row["counter"];

				$this->_phreezer->SetValueCache($cachekey, $this->_totalcount, $this->_cache_timeout);

				$this->UnlockCache($cachekey);
			}
		}

		return $this->_totalcount;
    }
function Count()
    {
		if (!$this->CountIsKnown())
		{
			// check the cache
			$cachekey = $this->_sql . " COUNT";
			$this->_totalcount = $this->GetDelayedCache($cachekey);

			// if no cache, go to the db
			if ($this->_totalcount != null)
			{
				$this->_phreezer->Observe("DataSet.Count: skipping count query because cache exists",OBSERVE_DEBUG);
			}
			else
			{
				$this->LockCache($cachekey);

				
				$sql = "";

				// if a custom counter sql query was provided, use that because it should be more efficient
				if ($this->CountSQL)
				{
					$this->_phreezer->Observe("DataSet.Count: using CountSQL to obtain total number of records",OBSERVE_DEBUG);
					$sql = $this->CountSQL;
				}
				else
				{
					$this->_phreezer->Observe("(DataSet.Count: CountSQL was not provided so a counter query will be generated.  Implement GetCustomCountQuery in the reporter class to improve performance.)",OBSERVE_WARN);
					$sql = "select count(1) as counter from (" . $this->_sql . ") tmptable" . rand(1000,9999);
				}

				$rs = $this->_phreezer->DataAdapter->Select($sql);
				$row = $this->_phreezer->DataAdapter->Fetch($rs);
				$this->_phreezer->DataAdapter->Release($rs);
				$this->_totalcount = $row["counter"];

				$this->_phreezer->SetValueCache($cachekey, $this->_totalcount, $this->_cache_timeout);

				$this->UnlockCache($cachekey);
			}
		}

		return $this->_totalcount;
    }
function Count ( ) { if ( ! $ this -> CountIsKnown ( ) ) { // check the cache
 $ cachekey = $ this -> _sql . " COUNT" ; $ this -> _totalcount = $ this -> GetDelayedCache ( $ cachekey ) ; // if no cache, go to the db
 if ( $ this -> _totalcount != null ) { $ this -> _phreezer -> Observe ( "DataSet.Count: skipping count query because cache exists" , OBSERVE_DEBUG ) ; } else { $ this -> LockCache ( $ cachekey ) ; $ sql = "" ; // if a custom counter sql query was provided, use that because it should be more efficient
 if ( $ this -> CountSQL ) { $ this -> _phreezer -> Observe ( "DataSet.Count: using CountSQL to obtain total number of records" , OBSERVE_DEBUG ) ; $ sql = $ this -> CountSQL ; } else { $ this -> _phreezer -> Observe ( "(DataSet.Count: CountSQL was not provided so a counter query will be generated.  Implement GetCustomCountQuery in the reporter class to improve performance.)" , OBSERVE_WARN ) ; $ sql = "select count(1) as counter from (" . $ this -> _sql . ") tmptable" . rand ( 1000 , 9999 ) ; } $ rs = $ this -> _phreezer -> DataAdapter -> Select ( $ sql ) ; $ row = $ this -> _phreezer -> DataAdapter -> Fetch ( $ rs ) ; $ this -> _phreezer -> DataAdapter -> Release ( $ rs ) ; $ this -> _totalcount = $ row [ "counter" ] ; $ this -> _phreezer -> SetValueCache ( $ cachekey , $ this -> _totalcount , $ this -> _cache_timeout ) ; $ this -> UnlockCache ( $ cachekey ) ; } } return $ this -> _totalcount ; }
Count returns the number of objects in the collection.  If the
count is not available, a count statement will be executed to determine the total
number of rows available

Note: if you get an "Unknown Column" error during a query, it may be due to tables being
joined in the wrong order.  To fix this, simply include references in your FieldMap to
the foreign tables in the same order that you wish them to be included in the query

@access     public
@return     int
Count returns the number of objects in the collection . If the count is not available a count statement will be executed to determine the total number of rows available