mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 14:58:42 +00:00
fix relation population
This commit is contained in:
parent
3997d9563e
commit
9e96b89aa0
|
|
@ -636,6 +636,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
self::createRelationTable($member, \is_array($id2) ? $id2 : [$id2], $id1);
|
self::createRelationTable($member, \is_array($id2) ? $id2 : [$id2], $id1);
|
||||||
|
self::removeInitialized(static::class, $id1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -2439,10 +2440,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
self::addInitialized(static::class, $value, $obj[$value]);
|
self::addInitialized(static::class, $value, $obj[$value]);
|
||||||
|
|
||||||
$obj[$value] = self::populateAbstract($row, $obj[$value], $depth);
|
$obj[$value] = self::populateAbstract($row, $obj[$value], $depth);
|
||||||
|
self::fillRelations($obj[$value], $relations, $depth - 1);
|
||||||
foreach (static::$hasMany as $many) {
|
|
||||||
self::fillRelations($obj[$value], $relations, $depth - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2510,10 +2508,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
$obj[$value] = self::populateAbstractArray($row, [], $depth);
|
$obj[$value] = self::populateAbstractArray($row, [], $depth);
|
||||||
|
|
||||||
self::addInitializedArray(static::class, $value, $obj[$value]);
|
self::addInitializedArray(static::class, $value, $obj[$value]);
|
||||||
|
self::fillRelationsArray($obj[$value], $relations, $depth - 1);
|
||||||
foreach (static::$hasMany as $many) {
|
|
||||||
self::fillRelationsArray(${$obj}[$value], $relations, $depth - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self::clear();
|
self::clear();
|
||||||
|
|
@ -2766,14 +2761,14 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = $obj[$mapper::$columns[$mapper::$primaryField]['internal']];
|
$key = $obj[static::$columns[static::$primaryField]['internal']];
|
||||||
|
|
||||||
if (empty($key)) {
|
if (empty($key)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* loading relations from relations table and populating them and then adding them to the object */
|
/* loading relations from relations table and populating them and then adding them to the object */
|
||||||
self::populateManyToManyArray(self::getHasManyRaw($key, $mapper, $relations), $obj[$key], $depth);
|
self::populateManyToManyArray(self::getHasManyRaw($key, $relations), $obj, $depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,7 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_direct')->execute();
|
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_direct')->execute();
|
||||||
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_rel')->execute();
|
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_rel')->execute();
|
||||||
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_rel_relations')->execute();
|
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE test_has_many_rel_relations')->execute();
|
||||||
|
BaseModelMapper::clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user