Skip to content
This repository has been archived by the owner on Aug 13, 2023. It is now read-only.

Commit

Permalink
Update Entity.php
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Apr 20, 2017
1 parent 80435ec commit d2b788c
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/ORM/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,21 +297,12 @@ protected function manyToMany(array &$config, array &$arguments)
$leftRightModel = $config['modelId'] ?: $model . ucfirst($pkModel);
$leftRightFrom = $config['itemId'] ?: $from . ucfirst($pkFrom);

// SELECT `right`.`*` FROM `roles` AS `right` INNER JOIN `usersRoles` AS `leftRight` ON (`right`.`id` = `leftRight`.`roleId`) WHERE ( (`leftRight`.`userId` = '1') )

$ids = $this->orm->repository($table)
->select($leftRightModel)
->where($leftRightFrom, $this->id())
->find(false);
->where($leftRightFrom, $this->id());

return $this->orm->repository($model)
->where($this->orm->mapPK($model), array_map('current', $ids));

// return $this->orm->repository(['right' => $model])
// ->select(['right.*'])
// ->join(['leftRight' => $table])->inner()
// ->on('right.' . $pkModel, 'leftRight.' . $leftRightModel)
// ->where('leftRight.' . $leftRightFrom, $this->id());
->where($this->orm->mapPK($model), 'IN', $ids);
}

/**
Expand Down

0 comments on commit d2b788c

Please sign in to comment.