original_string: 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();
      }
code: 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();
      }
code_tokens: 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 ( ) ; }
docstring: 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.
docstring_tokens: Loads a list of belongs to many from ids .