localObject = $localObject; $this->foreignObject = $foreignObject; $this->pivotTable = $pivotTable; $this->localInPivot = $localInPivot; $this->remoteInPivot = $remoteInPivot; $this->remoteFilter = $remoteFilter; $this->remoteLimit = $remoteLimit; } function get(){ $limitsSql = ''; foreach ($this->remoteLimit as $key => $value) { $limitsSql .= "$key $value "; } $pivotTable = '{' . $this->pivotTable . '}'; $sql = "SELECT * FROM $pivotTable WHERE $this->localInPivot = ? $limitsSql"; $relations = DBInstance::query($sql, Array($this->localObject->id), $this->localObject::_connectionName); $objects = Array(); if (empty($relations)) { return Array(); } foreach ($relations as $relation) { $relation->childElement = $this->foreignObject::findOne(array_merge(Array("id" => Array("=", $relation->{$this->remoteInPivot})), $this->remoteFilter)); $objects[] = $relation; } if (empty($objects)) { return Array(); } return $objects; } }