public function findByPrimary($pk_list = [])
    {
        $pk = $this->getPrimaryKey();
        $return = $this->newCollection();

        if ($pk_list) {
            $pk_list = array_unique($pk_list);
            foreach ($pk_list as $key => $value) {
                $item = $this->getRegistry()->get($value);
                if ($item) {
                    unset($pk_list[$key]);
                    $return[$item->{$pk}] = $item;
                }
            }
            if ($pk_list) {
                $query = $this->paramsToQuery();
                $query->where("$pk IN ?", $pk_list);
                $items = $this->findByQuery($query);

                if (count($items)) {
                    foreach ($items as $item) {
                        $this->getRegistry()->set($item->{$pk}, $item);
                        $return[$item->{$pk}] = $item;
                    }
                }
            }
        }

        return $return;
    }
public function findByPrimary($pk_list = [])
    {
        $pk = $this->getPrimaryKey();
        $return = $this->newCollection();

        if ($pk_list) {
            $pk_list = array_unique($pk_list);
            foreach ($pk_list as $key => $value) {
                $item = $this->getRegistry()->get($value);
                if ($item) {
                    unset($pk_list[$key]);
                    $return[$item->{$pk}] = $item;
                }
            }
            if ($pk_list) {
                $query = $this->paramsToQuery();
                $query->where("$pk IN ?", $pk_list);
                $items = $this->findByQuery($query);

                if (count($items)) {
                    foreach ($items as $item) {
                        $this->getRegistry()->set($item->{$pk}, $item);
                        $return[$item->{$pk}] = $item;
                    }
                }
            }
        }

        return $return;
    }
public function findByPrimary ( $ pk_list = [ ] ) { $ pk = $ this -> getPrimaryKey ( ) ; $ return = $ this -> newCollection ( ) ; if ( $ pk_list ) { $ pk_list = array_unique ( $ pk_list ) ; foreach ( $ pk_list as $ key => $ value ) { $ item = $ this -> getRegistry ( ) -> get ( $ value ) ; if ( $ item ) { unset ( $ pk_list [ $ key ] ) ; $ return [ $ item -> { $ pk } ] = $ item ; } } if ( $ pk_list ) { $ query = $ this -> paramsToQuery ( ) ; $ query -> where ( "$pk IN ?" , $ pk_list ) ; $ items = $ this -> findByQuery ( $ query ) ; if ( count ( $ items ) ) { foreach ( $ items as $ item ) { $ this -> getRegistry ( ) -> set ( $ item -> { $ pk } , $ item ) ; $ return [ $ item -> { $ pk } ] = $ item ; } } } } return $ return ; }
When searching by primary key, look for items in current registry before
fetching them from the database

@param array $pk_list
@return RecordCollection
When searching by primary key look for items in current registry before fetching them from the database