mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 15:18:41 +00:00
Fix array path bugs
This commit is contained in:
parent
71a13da619
commit
e36f56da30
|
|
@ -19,7 +19,7 @@ use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
use phpOMS\DataStorage\DataMapperInterface;
|
use phpOMS\DataStorage\DataMapperInterface;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\DataStorage\Database\Exception\InvalidMapperException;
|
use phpOMS\DataStorage\Database\Exception\InvalidMapperException;
|
||||||
use phpOMS\Util\ArrayUtils;
|
use phpOMS\Utils\ArrayUtils;
|
||||||
use phpOMS\DataStorage\Database\Query\QueryType;
|
use phpOMS\DataStorage\Database\Query\QueryType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -402,7 +402,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
$query->prefix(self::$db->getPrefix())->into(static::$table);
|
$query->prefix(self::$db->getPrefix())->into(static::$table);
|
||||||
|
|
||||||
foreach (static::$columns as $key => $column) {
|
foreach (static::$columns as $key => $column) {
|
||||||
$propertyName = $column['internal'];
|
$propertyName = stripos($column['internal'], '/') !== false ? explode('/', $column['internal'])[0] : $column['internal'];
|
||||||
if (isset(static::$hasMany[$propertyName]) || isset(static::$hasOne[$propertyName])) {
|
if (isset(static::$hasMany[$propertyName]) || isset(static::$hasOne[$propertyName])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -426,8 +426,10 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
} elseif ($column['name'] !== static::$primaryField) {
|
} elseif ($column['name'] !== static::$primaryField) {
|
||||||
$tValue = $property->getValue($obj);
|
$tValue = $property->getValue($obj);
|
||||||
if (stripos($column['internal'], '/') !== false) {
|
if (stripos($column['internal'], '/') !== false) {
|
||||||
$path = explode($column['internal']);
|
$path = explode('/', $column['internal']);
|
||||||
$path = implode('/', array_shift($path));
|
|
||||||
|
array_shift($path);
|
||||||
|
$path = implode('/', $path);
|
||||||
$tValue = ArrayUtils::getArray($path, $tValue, '/');
|
$tValue = ArrayUtils::getArray($path, $tValue, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -474,8 +476,10 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
|
|
||||||
$path = $column['internal'];
|
$path = $column['internal'];
|
||||||
if (stripos($column['internal'], '/') !== false) {
|
if (stripos($column['internal'], '/') !== false) {
|
||||||
$path = explode($column['internal']);
|
$path = explode('/', $column['internal']);
|
||||||
$path = implode('/', array_shift($path));
|
|
||||||
|
array_shift($path);
|
||||||
|
$path = implode('/', $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$property = ArrayUtils::getArray($path, $obj, '/');
|
$property = ArrayUtils::getArray($path, $obj, '/');
|
||||||
|
|
@ -1115,7 +1119,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
->where(static::$table . '.' . static::$primaryField, '=', $objId);
|
->where(static::$table . '.' . static::$primaryField, '=', $objId);
|
||||||
|
|
||||||
foreach (static::$columns as $key => $column) {
|
foreach (static::$columns as $key => $column) {
|
||||||
$propertyName = $column['internal'];
|
$propertyName = stripos($column['internal'], '/') !== false ? explode('/', $column['internal'])[0] : $column['internal'];
|
||||||
if (isset(static::$hasMany[$propertyName])
|
if (isset(static::$hasMany[$propertyName])
|
||||||
|| isset(static::$hasOne[$propertyName])
|
|| isset(static::$hasOne[$propertyName])
|
||||||
|| $column['internal'] === static::$primaryField
|
|| $column['internal'] === static::$primaryField
|
||||||
|
|
@ -1144,8 +1148,10 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
} elseif ($column['name'] !== static::$primaryField) {
|
} elseif ($column['name'] !== static::$primaryField) {
|
||||||
$tValue = $property->getValue($obj);
|
$tValue = $property->getValue($obj);
|
||||||
if (stripos($column['internal'], '/') !== false) {
|
if (stripos($column['internal'], '/') !== false) {
|
||||||
$path = explode($column['internal']);
|
$path = explode('/', $column['internal']);
|
||||||
$path = implode('/', array_shift($path));
|
|
||||||
|
array_shift($path);
|
||||||
|
$path = implode('/', $path);
|
||||||
$tValue = ArrayUtils::getArray($path, $tValue, '/');
|
$tValue = ArrayUtils::getArray($path, $tValue, '/');
|
||||||
}
|
}
|
||||||
$value = self::parseValue($column['type'], $tValue);
|
$value = self::parseValue($column['type'], $tValue);
|
||||||
|
|
@ -1773,7 +1779,9 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
if (stripos(static::$columns[$column]['internal'], '/') !== false) {
|
if (stripos(static::$columns[$column]['internal'], '/') !== false) {
|
||||||
$refProp = $refClass->getProperty(explode('/', static::$columns[$column]['internal'])[0]);
|
$refProp = $refClass->getProperty(explode('/', static::$columns[$column]['internal'])[0]);
|
||||||
$path = explode(static::$columns[$column]['internal']);
|
$path = explode(static::$columns[$column]['internal']);
|
||||||
$path = implode('/', array_shift($path));
|
|
||||||
|
array_shift($path);
|
||||||
|
$path = implode('/', $path);
|
||||||
$aValue = $refProp->getValue($obj);
|
$aValue = $refProp->getValue($obj);
|
||||||
} else {
|
} else {
|
||||||
$refProp = $refClass->getProperty(static::$columns[$column]['internal']);
|
$refProp = $refClass->getProperty(static::$columns[$column]['internal']);
|
||||||
|
|
@ -1840,8 +1848,10 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
if (isset(static::$columns[$column]['internal'])) {
|
if (isset(static::$columns[$column]['internal'])) {
|
||||||
$path = static::$columns[$column]['internal'];
|
$path = static::$columns[$column]['internal'];
|
||||||
if (stripos($path, '/') !== false) {
|
if (stripos($path, '/') !== false) {
|
||||||
$path = explode($path);
|
$path = explode('/', $path);
|
||||||
$path = implode('/', array_shift($path));
|
|
||||||
|
array_shift($path);
|
||||||
|
$path = implode('/', $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) {
|
if (in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user