Get child categories count

@param int $categoryId
@return int
482071
public function getChildrenCount($categoryId)
    {
        $select = $this->getConnection()->select()->from(
            $this->getEntityTable(),
            'children_count'
        )->where(
            'entity_id = :entity_id'
        );
        $bind = ['entity_id' => $categoryId];

        return $this->getConnection()->fetchOne($select, $bind);
    }
1007553
private function getCategoryNameById($categoryId, $storeId)
    {
        if (!isset($this->categoryNames[$categoryId])) {
            $categoryResource = $this->categoryResource;
            $this->categoryNames[$categoryId] = $categoryResource->getAttributeRawValue($categoryId, "name", $storeId);
        }

        return $this->categoryNames[$categoryId];
    }
303968
public static function get_name($categoryid) {
        global $PAGE;
        if ($categoryid === false || $categoryid == context_instance::INHERIT) {
            return get_string('inherit', 'tool_dataprivacy');
        } else if ($categoryid == context_instance::NOTSET) {
            return get_string('notset', 'tool_dataprivacy');
        } else {
            $purpose = new category($categoryid);
            $output = $PAGE->get_renderer('tool_dataprivacy');
            $exporter = new self($purpose, ['context' => \context_system::instance()]);
            $data = $exporter->export($output);
            return $data->name;
        }
    }
1109508
private function _countItemsInCategory($table, $catid)
	{
		$db = JFactory::getDbo();
		$query = $db->getQuery(true);

		// Count the items in this category
		$query->select('COUNT(id)')
			->from($table)
			->where('catid = ' . $catid);
		$db->setQuery($query);

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

			return false;
		}

		return $count;
	}
1331186
public function get_children_count() {
        $sortedids = self::get_tree($this->id);
        $invisibleids = $this->get_not_visible_children_ids();
        return count($sortedids) - count($invisibleids);
    }
578367
public static function getNumberOfPostChildren($postOrPostId = null)
    {
        $postId = self::extractPostId($postOrPostId);
        if ($postId < 1) {
            return false;
        }

        global $wpdb;
        return (int) $wpdb->get_var(
            $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_parent = %d", $postId)
        );
    }
429842
public function getVendorArticleCount($sVendorId)
    {
        // current category unique ident
        $sActIdent = $this->_getUserViewId();

        // loading from cache
        $aVendorData = $this->_getVendorCache();

        if (!$aVendorData || !isset($aVendorData[$sVendorId][$sActIdent])) {
            $iCnt = $this->setVendorArticleCount($aVendorData, $sVendorId, $sActIdent);
        } else {
            $iCnt = $aVendorData[$sVendorId][$sActIdent];
        }

        return $iCnt;
    }
700325
public static function findByNameCategoryId( $name, $categoryId ) {

		$optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION );

		return self::find()->where( "$optionTable.name=:name AND $optionTable.categoryId=:id", [ ':name' => $name, ':id' => $categoryId ] )->one();
	}
323093
public function getCategory($categoryId)
    {

        // try to load the category with the passed ID
        foreach ($this->categories as $category) {
            if ($category[MemberNames::ENTITY_ID] == $categoryId) {
                return $category;
            }
        }

        // throw an exception if the category is NOT available
        throw new \Exception(sprintf('Can\'t load category with ID %d in file %s on line %d', $categoryId));
    }
233116
public function countByFolderId($folderId)
    {
        $qb = $this->createQueryBuilder();

        $qb->field('mediaFolder.id')->equals($folderId);

        return $qb->getQuery()->count();
    }
504663
public function getCategory(int $categoryId, int $siteId) : array
    {
        Assert::that($categoryId)->greaterThan(0, 'The $categoryId has to be positive');
        Assert::that($siteId)->greaterThan(0, 'The $siteId has to be positive');

        return (array)$this->master->doRequest(
            'GET',
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductService/{KEY}/Category/%d/%d', $categoryId, $siteId)
        );
    }
870824
public function addChild(Category $category): Category
    {
        $this->children->add($category);

        if ($category->getParent() !== $this) {
            $category->setParent($this);
        }

        return $this;
    }
701930
public function countChildren(Criteria $criteria = null, ConnectionInterface $con = null)
    {
        if (null === $this->collNestedSetChildren || null !== $criteria) {
            if ($this->isLeaf() || ($this->isNew() && null === $this->collNestedSetChildren)) {
                return 0;
            } else {
                return ChildCategoryQuery::create(null, $criteria)
                    ->childrenOf($this)
                    ->count($con);
            }
        } else {
            return count($this->collNestedSetChildren);
        }
    }
195184
private function SaveCategoryPage($categoryID)
    {
        $category = Category::Schema()->ByID($categoryID);
        if ($category) {
            $category->SetPage($this->Page());
            $category->Save();
        }
    }
980285
private function get_category_from_group($categories) {
        global $DB;

        if (empty($categories)) {
            $catid = $this->get_default_category_id();
        } else {
            $createnewcategories = $this->get_config('createnewcategories');
            $categoryseparator = trim($this->get_config('categoryseparator'));
            $nestedcategories = trim($this->get_config('nestedcategories'));
            $searchbyidnumber = trim($this->get_config('categoryidnumber'));

            if (!empty($categoryseparator)) {
                $sep = '{\\'.$categoryseparator.'}';
            }

            $catid = 0;
            $fullnestedcatname = '';

            foreach ($categories as $categoryinfo) {
                if ($searchbyidnumber) {
                    $values = preg_split($sep, $categoryinfo, -1, PREG_SPLIT_NO_EMPTY);
                    if (count($values) < 2) {
                        $this->log_line('Category ' . $categoryinfo . ' missing name or idnumber. Using default category instead.');
                        $catid = $this->get_default_category_id();
                        break;
                    }
                    $categoryname = $values[0];
                    $categoryidnumber = $values[1];
                } else {
                    $categoryname = $categoryinfo;
                    $categoryidnumber = null;
                    if (empty($categoryname)) {
                        $this->log_line('Category ' . $categoryinfo . ' missing name. Using default category instead.');
                        $catid = $this->get_default_category_id();
                        break;
                    }
                }

                if (!empty($fullnestedcatname)) {
                    $fullnestedcatname .= ' / ';
                }

                $fullnestedcatname .= $categoryname;
                $parentid = $catid;

                // Check if category exist.
                $params = array();
                if ($searchbyidnumber) {
                    $params['idnumber'] = $categoryidnumber;
                } else {
                    $params['name'] = $categoryname;
                }
                if ($nestedcategories) {
                    $params['parent'] = $parentid;
                }

                if ($catid = $DB->get_field('course_categories', 'id', $params)) {
                    continue; // This category already exists.
                }

                // If we're allowed to create new categories, let's create this one.
                if ($createnewcategories) {
                    $newcat = new stdClass();
                    $newcat->name = $categoryname;
                    $newcat->visible = 0;
                    $newcat->parent = $parentid;
                    $newcat->idnumber = $categoryidnumber;
                    $newcat = core_course_category::create($newcat);
                    $catid = $newcat->id;
                    $this->log_line("Created new (hidden) category '$fullnestedcatname'");
                } else {
                    // If not found and not allowed to create, stick with default.
                    $this->log_line('Category ' . $categoryinfo . ' not found in Moodle database. Using default category instead.');
                    $catid = $this->get_default_category_id();
                    break;
                }
            }
        }

        return $catid;
    }
574774
private function getChildren($parentID)
    {
        $tmp = [];
        $count = 0;
        foreach($this->existingMenuLinks as $key => $menuLink){
            if ($menuLink['parent'] == $parentID) {
                $tmp[$count] = $menuLink;
                $count++;
            }
        }
        return $tmp;
    }
936057
public function countTotal($actorId = null)
    {
        $qb = $this->getQueryBuilder()
            ->select('COUNT(t)');

        if (!is_null($actorId)) {
            $qb->where('t.actor = :actor_id')
                ->setParameter('actor_id', $actorId);
        }

        return $qb->getQuery()
            ->getSingleScalarResult();
    }