plugins/content/categories/categories.php
private function _countItemsInChildren($table, $catid, $data)
	{
		$db = JFactory::getDbo();

		// Create subquery for list of child categories
		$childCategoryTree = $data->getTree();

		// First element in tree is the current category, so we can skip that one
		unset($childCategoryTree[0]);
		$childCategoryIds = array();

		foreach ($childCategoryTree as $node)
		{
			$childCategoryIds[] = $node->id;
		}

		// Make sure we only do the query if we have some categories to look in
		if (count($childCategoryIds))
		{
			// Count the items in this category
			$query = $db->getQuery(true)
				->select('COUNT(id)')
				->from($table)
				->where('catid IN (' . implode(',', $childCategoryIds) . ')');
			$db->setQuery($query);

			try
			{
				$count = $db->loadResult();
			}
			catch (RuntimeException $e)
			{
				JError::raiseWarning(500, $e->getMessage());

				return false;
			}

			return $count;
		}
		else
			// If we didn't have any categories to check, return 0
		{
			return 0;
		}
	}
private function _countItemsInChildren($table, $catid, $data)
	{
		$db = JFactory::getDbo();

		// Create subquery for list of child categories
		$childCategoryTree = $data->getTree();

		// First element in tree is the current category, so we can skip that one
		unset($childCategoryTree[0]);
		$childCategoryIds = array();

		foreach ($childCategoryTree as $node)
		{
			$childCategoryIds[] = $node->id;
		}

		// Make sure we only do the query if we have some categories to look in
		if (count($childCategoryIds))
		{
			// Count the items in this category
			$query = $db->getQuery(true)
				->select('COUNT(id)')
				->from($table)
				->where('catid IN (' . implode(',', $childCategoryIds) . ')');
			$db->setQuery($query);

			try
			{
				$count = $db->loadResult();
			}
			catch (RuntimeException $e)
			{
				JError::raiseWarning(500, $e->getMessage());

				return false;
			}

			return $count;
		}
		else
			// If we didn't have any categories to check, return 0
		{
			return 0;
		}
	}
private function _countItemsInChildren ( $ table , $ catid , $ data ) { $ db = JFactory :: getDbo ( ) ; // Create subquery for list of child categories $ childCategoryTree = $ data -> getTree ( ) ; // First element in tree is the current category, so we can skip that one unset ( $ childCategoryTree [ 0 ] ) ; $ childCategoryIds = array ( ) ; foreach ( $ childCategoryTree as $ node ) { $ childCategoryIds [ ] = $ node -> id ; } // Make sure we only do the query if we have some categories to look in if ( count ( $ childCategoryIds ) ) { // Count the items in this category $ query = $ db -> getQuery ( true ) -> select ( 'COUNT(id)' ) -> from ( $ table ) -> where ( 'catid IN (' . implode ( ',' , $ childCategoryIds ) . ')' ) ; $ db -> setQuery ( $ query ) ; try { $ count = $ db -> loadResult ( ) ; } catch ( RuntimeException $ e ) { JError :: raiseWarning ( 500 , $ e -> getMessage ( ) ) ; return false ; } return $ count ; } else // If we didn't have any categories to check, return 0 { return 0 ; } }
Get count of items in a category's child categories

@param   string   $table  table name of component table (column is catid)
@param   integer  $catid  id of the category to check
@param   object   $data   The data relating to the content that was deleted.

@return  mixed  count of items found or false if db error

@since   1.6
Get count of items in a category s child categories