private static function getChildrenIdRec($ids, $className, $primaryKey, $parentIdField, $recursive)
    {
        $subIds = array_map('intval', $className::find()
            ->select($primaryKey)
            ->where([ $parentIdField => $ids ])
            ->column());
        if ( $subIds ) {
            if ( $recursive ) {
                return array_merge($subIds, self::getChildrenIdRec($subIds, $className, $primaryKey, $parentIdField, true));
            } else {
                return $subIds;
            }
        } else {
            return [];
        }
    }
private static function getChildrenIdRec($ids, $className, $primaryKey, $parentIdField, $recursive)
    {
        $subIds = array_map('intval', $className::find()
            ->select($primaryKey)
            ->where([ $parentIdField => $ids ])
            ->column());
        if ( $subIds ) {
            if ( $recursive ) {
                return array_merge($subIds, self::getChildrenIdRec($subIds, $className, $primaryKey, $parentIdField, true));
            } else {
                return $subIds;
            }
        } else {
            return [];
        }
    }
private static function getChildrenIdRec ( $ ids , $ className , $ primaryKey , $ parentIdField , $ recursive ) { $ subIds = array_map ( 'intval' , $ className :: find ( ) -> select ( $ primaryKey ) -> where ( [ $ parentIdField => $ ids ] ) -> column ( ) ) ; if ( $ subIds ) { if ( $ recursive ) { return array_merge ( $ subIds , self :: getChildrenIdRec ( $ subIds , $ className , $ primaryKey , $ parentIdField , true ) ) ; } else { return $ subIds ; } } else { return [ ] ; } }
Recursive method to get all children id, including subid
@param array|integer $ids
@param string $className
@param string $primaryKey
@param string $parentIdField
@param boolean $recursive
@return integer[]
Recursive method to get all children id including subid