mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-11 22:38:42 +00:00
Relations create+formatting
This commit is contained in:
parent
d44f18963d
commit
e02de0b5a4
|
|
@ -235,7 +235,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function create($obj)
|
public function create($obj, bool $relations = true)
|
||||||
{
|
{
|
||||||
// todo: create should also have an option to create relations (default = true)
|
// todo: create should also have an option to create relations (default = true)
|
||||||
$query = new Builder($this->db);
|
$query = new Builder($this->db);
|
||||||
|
|
@ -278,6 +278,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
$objId = $this->db->con->lastInsertId();
|
$objId = $this->db->con->lastInsertId();
|
||||||
|
|
||||||
// handle relations
|
// handle relations
|
||||||
|
if($relations) {
|
||||||
foreach (static::$hasMany as $member => $rel) {
|
foreach (static::$hasMany as $member => $rel) {
|
||||||
/* is a has many property */
|
/* is a has many property */
|
||||||
$property = $reflectionClass->getProperty($member); // throws ReflectionException
|
$property = $reflectionClass->getProperty($member); // throws ReflectionException
|
||||||
|
|
@ -346,6 +347,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
$this->db->con->prepare($relQuery->toSql())->execute();
|
$this->db->con->prepare($relQuery->toSql())->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// todo: should be done by primaryfield since it could be something else than id
|
// todo: should be done by primaryfield since it could be something else than id
|
||||||
$reflectionProperty = $reflectionClass->getProperty('id');
|
$reflectionProperty = $reflectionClass->getProperty('id');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user