src/ORM/DataList.php
public function setByIDList($idList)
    {
        $has = [];

        // Index current data
        foreach ($this->column() as $id) {
            $has[$id] = true;
        }

        // Keep track of items to delete
        $itemsToDelete = $has;

        // add items in the list
        // $id is the database ID of the record
        if ($idList) {
            foreach ($idList as $id) {
                unset($itemsToDelete[$id]);
                if ($id && !isset($has[$id])) {
                    $this->add($id);
                }
            }
        }

        // Remove any items that haven't been mentioned
        $this->removeMany(array_keys($itemsToDelete));
    }
public function setByIDList($idList)
    {
        $has = [];

        // Index current data
        foreach ($this->column() as $id) {
            $has[$id] = true;
        }

        // Keep track of items to delete
        $itemsToDelete = $has;

        // add items in the list
        // $id is the database ID of the record
        if ($idList) {
            foreach ($idList as $id) {
                unset($itemsToDelete[$id]);
                if ($id && !isset($has[$id])) {
                    $this->add($id);
                }
            }
        }

        // Remove any items that haven't been mentioned
        $this->removeMany(array_keys($itemsToDelete));
    }
public function setByIDList ( $ idList ) { $ has = [ ] ; // Index current data foreach ( $ this -> column ( ) as $ id ) { $ has [ $ id ] = true ; } // Keep track of items to delete $ itemsToDelete = $ has ; // add items in the list // $id is the database ID of the record if ( $ idList ) { foreach ( $ idList as $ id ) { unset ( $ itemsToDelete [ $ id ] ) ; if ( $ id && ! isset ( $ has [ $ id ] ) ) { $ this -> add ( $ id ) ; } } } // Remove any items that haven't been mentioned $ this -> removeMany ( array_keys ( $ itemsToDelete ) ) ; }
Sets the ComponentSet to be the given ID list.
Records will be added and deleted as appropriate.

@param array $idList List of IDs.
Sets the ComponentSet to be the given ID list . Records will be added and deleted as appropriate .