private static function fetchData(databox $databox, array $subdefIds)
    {
        $found = [];
        $missing = [];

        foreach ($subdefIds as $index => $subdefId) {
            try {
                $data = self::doGetDataFromCache($databox, $subdefId);
            } catch (Exception $exception) {
                $data = false;
            }

            if (is_array($data)) {
                $found[$index] = $data;

                continue;
            }

            $missing[$index] = $subdefId;
        }

        if (!$missing) {
            return $found;
        }

        $dbalData = $databox->get_connection()->fetchAll(
            self::getSelectSql(),
            ['subdef_id' => array_values($missing)],
            ['subdef_id' => Connection::PARAM_INT_ARRAY]
        );

        foreach ($dbalData as $item) {
            $itemSubdefId = $item['subdef_id'];

            $databox->set_data_to_cache($item, self::generateCacheKey($itemSubdefId));

            $foundIndexes = array_keys(array_intersect($missing, [$itemSubdefId]));

            foreach ($foundIndexes as $foundIndex) {
                $found[$foundIndex] = $item;
                unset($missing[$foundIndex]);
            }
        }

        return $found;
    }
private static function fetchData(databox $databox, array $subdefIds)
    {
        $found = [];
        $missing = [];

        foreach ($subdefIds as $index => $subdefId) {
            try {
                $data = self::doGetDataFromCache($databox, $subdefId);
            } catch (Exception $exception) {
                $data = false;
            }

            if (is_array($data)) {
                $found[$index] = $data;

                continue;
            }

            $missing[$index] = $subdefId;
        }

        if (!$missing) {
            return $found;
        }

        $dbalData = $databox->get_connection()->fetchAll(
            self::getSelectSql(),
            ['subdef_id' => array_values($missing)],
            ['subdef_id' => Connection::PARAM_INT_ARRAY]
        );

        foreach ($dbalData as $item) {
            $itemSubdefId = $item['subdef_id'];

            $databox->set_data_to_cache($item, self::generateCacheKey($itemSubdefId));

            $foundIndexes = array_keys(array_intersect($missing, [$itemSubdefId]));

            foreach ($foundIndexes as $foundIndex) {
                $found[$foundIndex] = $item;
                unset($missing[$foundIndex]);
            }
        }

        return $found;
    }
private static function fetchData ( databox $ databox , array $ subdefIds ) { $ found = [ ] ; $ missing = [ ] ; foreach ( $ subdefIds as $ index => $ subdefId ) { try { $ data = self :: doGetDataFromCache ( $ databox , $ subdefId ) ; } catch ( Exception $ exception ) { $ data = false ; } if ( is_array ( $ data ) ) { $ found [ $ index ] = $ data ; continue ; } $ missing [ $ index ] = $ subdefId ; } if ( ! $ missing ) { return $ found ; } $ dbalData = $ databox -> get_connection ( ) -> fetchAll ( self :: getSelectSql ( ) , [ 'subdef_id' => array_values ( $ missing ) ] , [ 'subdef_id' => Connection :: PARAM_INT_ARRAY ] ) ; foreach ( $ dbalData as $ item ) { $ itemSubdefId = $ item [ 'subdef_id' ] ; $ databox -> set_data_to_cache ( $ item , self :: generateCacheKey ( $ itemSubdefId ) ) ; $ foundIndexes = array_keys ( array_intersect ( $ missing , [ $ itemSubdefId ] ) ) ; foreach ( $ foundIndexes as $ foundIndex ) { $ found [ $ foundIndex ] = $ item ; unset ( $ missing [ $ foundIndex ] ) ; } } return $ found ; }
Returns present data in storage with same indexes but different order

@param databox $databox
@param int[] $subdefIds
@return array
Returns present data in storage with same indexes but different order