protected function _loadAssociatedByIds($assoc, $ids)
    {
        if (empty($ids)) {
            return [];
        }

        $target = $assoc->getTarget();
        $primaryKey = (array)$target->getPrimaryKey();
        $multi = count($primaryKey) > 1;
        $primaryKey = array_map([$target, 'aliasField'], $primaryKey);

        if ($multi) {
            $first = current($ids);
            if (!is_array($first) || count($first) !== count($primaryKey)) {
                return [];
            }
            $filter = new TupleComparison($primaryKey, $ids, [], 'IN');
        } else {
            $filter = [$primaryKey[0] . ' IN' => $ids];
        }

        return $target->find()->where($filter)->toArray();
    }
protected function _loadAssociatedByIds($assoc, $ids)
    {
        if (empty($ids)) {
            return [];
        }

        $target = $assoc->getTarget();
        $primaryKey = (array)$target->getPrimaryKey();
        $multi = count($primaryKey) > 1;
        $primaryKey = array_map([$target, 'aliasField'], $primaryKey);

        if ($multi) {
            $first = current($ids);
            if (!is_array($first) || count($first) !== count($primaryKey)) {
                return [];
            }
            $filter = new TupleComparison($primaryKey, $ids, [], 'IN');
        } else {
            $filter = [$primaryKey[0] . ' IN' => $ids];
        }

        return $target->find()->where($filter)->toArray();
    }
protected function _loadAssociatedByIds ( $ assoc , $ ids ) { if ( empty ( $ ids ) ) { return [ ] ; } $ target = $ assoc -> getTarget ( ) ; $ primaryKey = ( array ) $ target -> getPrimaryKey ( ) ; $ multi = count ( $ primaryKey ) > 1 ; $ primaryKey = array_map ( [ $ target , 'aliasField' ] , $ primaryKey ) ; if ( $ multi ) { $ first = current ( $ ids ) ; if ( ! is_array ( $ first ) || count ( $ first ) !== count ( $ primaryKey ) ) { return [ ] ; } $ filter = new TupleComparison ( $ primaryKey , $ ids , [ ] , 'IN' ) ; } else { $ filter = [ $ primaryKey [ 0 ] . ' IN' => $ ids ] ; } return $ target -> find ( ) -> where ( $ filter ) -> toArray ( ) ; }
Loads a list of belongs to many from ids.

@param \Cake\ORM\Association $assoc The association class for the belongsToMany association.
@param array $ids The list of ids to load.
@return \Cake\Datasource\EntityInterface[] An array of entities.
Loads a list of belongs to many from ids .