Atualizar 'src/BBOrm/Entity.php'
This commit is contained in:
@@ -289,7 +289,11 @@ abstract class Entity {
|
|||||||
|
|
||||||
protected function belongs_to_many($foreign_object, $pivot_table, $local_in_pivot, $remote_in_pivot, $remote_filter = Array(), $remote_limit = Array()) {
|
protected function belongs_to_many($foreign_object, $pivot_table, $local_in_pivot, $remote_in_pivot, $remote_filter = Array(), $remote_limit = Array()) {
|
||||||
$obj = new $foreign_object;
|
$obj = new $foreign_object;
|
||||||
|
$limits_sql = '';
|
||||||
|
|
||||||
|
foreach ($remote_limit as $key => $value) {
|
||||||
|
$limits_sql .= "$key $value ";
|
||||||
|
}
|
||||||
$sql = "SELECT $remote_in_pivot FROM $pivot_table WHERE $local_in_pivot = $this->id $limits_sql";
|
$sql = "SELECT $remote_in_pivot FROM $pivot_table WHERE $local_in_pivot = $this->id $limits_sql";
|
||||||
|
|
||||||
$relations = DBInstance::query($sql, $this->connection_name);
|
$relations = DBInstance::query($sql, $this->connection_name);
|
||||||
@@ -318,7 +322,7 @@ abstract class Entity {
|
|||||||
return Array();
|
return Array();
|
||||||
}
|
}
|
||||||
foreach ($relations as $relation) {
|
foreach ($relations as $relation) {
|
||||||
$relation->child_element = $obj->find_one(array_merge(Array("id" => Array("=", $relation->$remote_in_pivot), $remote_filter)));
|
$relation->child_element = $obj->find_one(array_merge(Array("id" => Array("=", $relation->$remote_in_pivot)), $remote_filter ));
|
||||||
$objects[] = $relation;
|
$objects[] = $relation;
|
||||||
}
|
}
|
||||||
if (empty($objects)) {
|
if (empty($objects)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user