public static function addRowsToMap($rows)
    {
        $firstRow = reset($rows);
        $idAttribute = static::getIdAttribute();
        if ($firstRow instanceof ActiveRecord) {
            foreach ($rows as $row) {
                self::$identityMap[$row[$idAttribute]] = $row->toArray();
                foreach (static::getUniqueAttributes() as $uniqueAttribute) {
                    self::$uniqueAttributeToId[$uniqueAttribute][$row[$uniqueAttribute]] = $row[$idAttribute];
                }
            }
        } else {
            foreach ($rows as $row) {
                self::$identityMap[$row[$idAttribute]] = $row;
                foreach (static::getUniqueAttributes() as $uniqueAttribute) {
                    self::$uniqueAttributeToId[$uniqueAttribute][$row[$uniqueAttribute]] = $row[$idAttribute];
                }
            }
        }
        $maxSize = self::getIdentityMapMaxSize();
        if ($maxSize !== -1) {
            $count = count(self::$identityMap);
            if ($count > $maxSize) {
                self::$identityMap = array_slice(
                    self::$identityMap,
                    $count - $maxSize,
                    $maxSize
                );
            }
        }
    }
public static function addRowsToMap($rows)
    {
        $firstRow = reset($rows);
        $idAttribute = static::getIdAttribute();
        if ($firstRow instanceof ActiveRecord) {
            foreach ($rows as $row) {
                self::$identityMap[$row[$idAttribute]] = $row->toArray();
                foreach (static::getUniqueAttributes() as $uniqueAttribute) {
                    self::$uniqueAttributeToId[$uniqueAttribute][$row[$uniqueAttribute]] = $row[$idAttribute];
                }
            }
        } else {
            foreach ($rows as $row) {
                self::$identityMap[$row[$idAttribute]] = $row;
                foreach (static::getUniqueAttributes() as $uniqueAttribute) {
                    self::$uniqueAttributeToId[$uniqueAttribute][$row[$uniqueAttribute]] = $row[$idAttribute];
                }
            }
        }
        $maxSize = self::getIdentityMapMaxSize();
        if ($maxSize !== -1) {
            $count = count(self::$identityMap);
            if ($count > $maxSize) {
                self::$identityMap = array_slice(
                    self::$identityMap,
                    $count - $maxSize,
                    $maxSize
                );
            }
        }
    }
public static function addRowsToMap ( $ rows ) { $ firstRow = reset ( $ rows ) ; $ idAttribute = static :: getIdAttribute ( ) ; if ( $ firstRow instanceof ActiveRecord ) { foreach ( $ rows as $ row ) { self :: $ identityMap [ $ row [ $ idAttribute ] ] = $ row -> toArray ( ) ; foreach ( static :: getUniqueAttributes ( ) as $ uniqueAttribute ) { self :: $ uniqueAttributeToId [ $ uniqueAttribute ] [ $ row [ $ uniqueAttribute ] ] = $ row [ $ idAttribute ] ; } } } else { foreach ( $ rows as $ row ) { self :: $ identityMap [ $ row [ $ idAttribute ] ] = $ row ; foreach ( static :: getUniqueAttributes ( ) as $ uniqueAttribute ) { self :: $ uniqueAttributeToId [ $ uniqueAttribute ] [ $ row [ $ uniqueAttribute ] ] = $ row [ $ idAttribute ] ; } } } $ maxSize = self :: getIdentityMapMaxSize ( ) ; if ( $ maxSize !== - 1 ) { $ count = count ( self :: $ identityMap ) ; if ( $ count > $ maxSize ) { self :: $ identityMap = array_slice ( self :: $ identityMap , $ count - $ maxSize , $ maxSize ) ; } } }
Add rows to identity map
@param ActiveRecord[]|array[] $rows
Add rows to identity map