Mudanças

This commit is contained in:
ahwelp
2022-04-05 20:03:21 +00:00
parent 1669a4279d
commit 477f3696ba
5 changed files with 57 additions and 35 deletions
+8 -8
View File
@@ -23,27 +23,27 @@ class BelongsToMany {
}
function get() {
$limitsSql = '';
foreach ($this->remoteLimit as $key => $value) {
$limitsSql .= "$key $value ";
}
$pivotTable = '{' . $this->pivotTable . '}';
$pivotTable = '{' . $this->pivotTable . '}';
$sql = "SELECT $this->remoteInPivot FROM $pivotTable WHERE $this->localInPivot = ? $limitsSql";
$relations = DBInstance::query($sql, Array($this->localObject->id), $this->localObject::_connectionName);
$ids = Array();
$ids = Array();
foreach ($relations as $relation) {
$ids[] = $relation->{$this->remoteInPivot};
}
if (empty($ids)) {
return Array();
}
return $this->foreignObject::findMany(array_merge(Array('id' => Array('IN', $ids)), $this->remoteFilter), Array('*'), $this->remoteLimit);
return $this->foreignObject::findMany(array_merge(Array('id' => Array('IN', $ids)), $this->remoteFilter), Array('*'), $this->remoteLimit);
}
}