mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-19 21:18:39 +00:00
fix phpstan/phpcs
This commit is contained in:
parent
5ed284a1d1
commit
580460dc11
|
|
@ -1948,22 +1948,22 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$obj = [];
|
||||
|
||||
foreach ($result as $element) {
|
||||
if (isset($element[static::$primaryField . '_' . $depth])
|
||||
&& self::isInitialized(static::class, $element[static::$primaryField . '_' . $depth], $depth)
|
||||
if (isset($element[static::$primaryField . '_d' . $depth])
|
||||
&& self::isInitialized(static::class, $element[static::$primaryField . '_d' . $depth], $depth)
|
||||
) {
|
||||
$obj[$element[static::$primaryField . '_' . $depth]] = self::$initObjects[static::class][$element[static::$primaryField . '_' . $depth]['obj']];
|
||||
$obj[$element[static::$primaryField . '_d' . $depth]] = self::$initObjects[static::class][$element[static::$primaryField . '_d' . $depth]['obj']];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$toFill = self::createBaseModel();
|
||||
|
||||
if (!isset($element[static::$primaryField . '_' . $depth])) {
|
||||
if (!isset($element[static::$primaryField . '_d' . $depth])) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
$obj[$element[static::$primaryField . '_' . $depth]] = self::populateAbstract($element, $toFill, $depth);
|
||||
self::addInitialized(static::class, $element[static::$primaryField . '_' . $depth], $obj[$element[static::$primaryField . '_' . $depth]], $depth);
|
||||
$obj[$element[static::$primaryField . '_d' . $depth]] = self::populateAbstract($element, $toFill, $depth);
|
||||
self::addInitialized(static::class, $element[static::$primaryField . '_d' . $depth], $obj[$element[static::$primaryField . '_d' . $depth]], $depth);
|
||||
}
|
||||
|
||||
return $obj;
|
||||
|
|
@ -2099,24 +2099,24 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$mapper = static::$ownsOne[$member]['mapper'];
|
||||
|
||||
if ($depth < 1) {
|
||||
if (\array_key_exists(static::$ownsOne[$member]['external'] . '_' . ($depth + 1), $result)) {
|
||||
if (\array_key_exists(static::$ownsOne[$member]['external'] . '_d' . ($depth + 1), $result)) {
|
||||
return isset(static::$ownsOne[$member]['column'])
|
||||
? $result[static::$ownsOne[$member]['external'] . '_' . ($depth + 1)]
|
||||
: $mapper::createNullModel($result[static::$ownsOne[$member]['external'] . '_' . ($depth + 1)]);
|
||||
? $result[static::$ownsOne[$member]['external'] . '_d' . ($depth + 1)]
|
||||
: $mapper::createNullModel($result[static::$ownsOne[$member]['external'] . '_d' . ($depth + 1)]);
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset(static::$ownsOne[$member]['column'])) {
|
||||
return $result[$mapper::getColumnByMember(static::$ownsOne[$member]['column']) . '_' . $depth];
|
||||
return $result[$mapper::getColumnByMember(static::$ownsOne[$member]['column']) . '_d' . $depth];
|
||||
}
|
||||
|
||||
if (!isset($result[$mapper::$primaryField . '_' . $depth])) {
|
||||
if (!isset($result[$mapper::$primaryField . '_d' . $depth])) {
|
||||
return $mapper::createNullModel();
|
||||
}
|
||||
|
||||
$obj = $mapper::getInitialized($mapper, $result[$mapper::$primaryField . '_' . $depth], $depth);
|
||||
$obj = $mapper::getInitialized($mapper, $result[$mapper::$primaryField . '_d' . $depth], $depth);
|
||||
|
||||
return $obj ?? $mapper::populateAbstract($result, $mapper::createBaseModel(), $depth);
|
||||
}
|
||||
|
|
@ -2139,22 +2139,22 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$mapper = static::$ownsOne[$member]['mapper'];
|
||||
|
||||
if ($depth < 1) {
|
||||
if (\array_key_exists(static::$ownsOne[$member]['external'] . '_' . ($depth + 1), $result)) {
|
||||
return $result[static::$ownsOne[$member]['external'] . '_' . ($depth + 1)];
|
||||
if (\array_key_exists(static::$ownsOne[$member]['external'] . '_d' . ($depth + 1), $result)) {
|
||||
return $result[static::$ownsOne[$member]['external'] . '_d' . ($depth + 1)];
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset(static::$ownsOne[$member]['column'])) {
|
||||
return $result[$mapper::getColumnByMember(static::$ownsOne[$member]['column']) . '_' . $depth];
|
||||
return $result[$mapper::getColumnByMember(static::$ownsOne[$member]['column']) . '_d' . $depth];
|
||||
}
|
||||
|
||||
if (!isset($result[$mapper::$primaryField . '_' . $depth])) {
|
||||
if (!isset($result[$mapper::$primaryField . '_d' . $depth])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$obj = $mapper::getInitializedArray($mapper, $result[$mapper::$primaryField . '_' . $depth], $depth);
|
||||
$obj = $mapper::getInitializedArray($mapper, $result[$mapper::$primaryField . '_d' . $depth], $depth);
|
||||
|
||||
return $obj ?? $mapper::populateAbstractArray($result, [], $depth);
|
||||
}
|
||||
|
|
@ -2180,20 +2180,20 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$mapper = static::$belongsTo[$member]['mapper'];
|
||||
|
||||
if ($depth < 1) {
|
||||
if (\array_key_exists(static::$belongsTo[$member]['external'] . '_' . ($depth + 1), $result)) {
|
||||
if (\array_key_exists(static::$belongsTo[$member]['external'] . '_d' . ($depth + 1), $result)) {
|
||||
return isset(static::$belongsTo[$member]['column'])
|
||||
? $result[static::$belongsTo[$member]['external'] . '_' . ($depth + 1)]
|
||||
: $mapper::createNullModel($result[static::$belongsTo[$member]['external'] . '_' . ($depth + 1)]);
|
||||
? $result[static::$belongsTo[$member]['external'] . '_d' . ($depth + 1)]
|
||||
: $mapper::createNullModel($result[static::$belongsTo[$member]['external'] . '_d' . ($depth + 1)]);
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset(static::$belongsTo[$member]['column'])) {
|
||||
return $result[$mapper::getColumnByMember(static::$belongsTo[$member]['column']) . '_' . $depth];
|
||||
return $result[$mapper::getColumnByMember(static::$belongsTo[$member]['column']) . '_d' . $depth];
|
||||
}
|
||||
|
||||
if (!isset($result[$mapper::$primaryField . '_' . $depth])) {
|
||||
if (!isset($result[$mapper::$primaryField . '_d' . $depth])) {
|
||||
return $mapper::createNullModel();
|
||||
}
|
||||
|
||||
|
|
@ -2202,10 +2202,10 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
// you want the profile but the account id is referenced
|
||||
// in this case you can get the profile by loading the profile based on the account reference column
|
||||
if (isset(static::$belongsTo[$member]['by'])) {
|
||||
return $mapper::getBy($result[$mapper::getColumnByMember(static::$belongsTo[$member]['by']) . '_' . $depth], static::$belongsTo[$member]['by']);
|
||||
return $mapper::getBy($result[$mapper::getColumnByMember(static::$belongsTo[$member]['by']) . '_d' . $depth], static::$belongsTo[$member]['by']);
|
||||
}
|
||||
|
||||
$obj = $mapper::getInitialized($mapper, $result[$mapper::$primaryField . '_' . $depth], $depth);
|
||||
$obj = $mapper::getInitialized($mapper, $result[$mapper::$primaryField . '_d' . $depth], $depth);
|
||||
|
||||
return $obj ?? $mapper::populateAbstract($result, $mapper::createBaseModel(), $depth);
|
||||
}
|
||||
|
|
@ -2228,22 +2228,22 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$mapper = static::$belongsTo[$member]['mapper'];
|
||||
|
||||
if ($depth < 1) {
|
||||
if (\array_key_exists(static::$belongsTo[$member]['external'] . '_' . ($depth + 1), $result)) {
|
||||
return $result[static::$belongsTo[$member]['external'] . '_' . ($depth + 1)];
|
||||
if (\array_key_exists(static::$belongsTo[$member]['external'] . '_d' . ($depth + 1), $result)) {
|
||||
return $result[static::$belongsTo[$member]['external'] . '_d' . ($depth + 1)];
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset(static::$belongsTo[$member]['column'])) {
|
||||
return $result[$mapper::getColumnByMember(static::$belongsTo[$member]['column']) . '_' . $depth];
|
||||
return $result[$mapper::getColumnByMember(static::$belongsTo[$member]['column']) . '_d' . $depth];
|
||||
}
|
||||
|
||||
if (!isset($result[$mapper::$primaryField . '_' . $depth])) {
|
||||
if (!isset($result[$mapper::$primaryField . '_d' . $depth])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$obj = $mapper::getInitializedArray($mapper, $result[$mapper::$primaryField . '_' . $depth], $depth);
|
||||
$obj = $mapper::getInitializedArray($mapper, $result[$mapper::$primaryField . '_d' . $depth], $depth);
|
||||
|
||||
return $obj ?? $mapper::populateAbstractArray($result, [], $depth);
|
||||
}
|
||||
|
|
@ -2266,7 +2266,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$refClass = new \ReflectionClass($obj);
|
||||
|
||||
foreach (static::$columns as $column => $def) {
|
||||
$alias = $column . '_' . $depth;
|
||||
$alias = $column . '_d' . $depth;
|
||||
|
||||
if (!\array_key_exists($alias, $result)) {
|
||||
continue;
|
||||
|
|
@ -2374,7 +2374,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
|
||||
foreach (static::$hasMany as $member => $def) {
|
||||
$column = $def['mapper']::getColumnByMember($def['column'] ?? $member);
|
||||
$alias = $column . '_' . ($depth - 1);
|
||||
$alias = $column . '_d' . ($depth - 1);
|
||||
|
||||
if (!\array_key_exists($alias, $result) || !isset($def['column'])) {
|
||||
continue;
|
||||
|
|
@ -2462,7 +2462,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
public static function populateAbstractArray(array $result, array $obj = [], int $depth = 3) : array
|
||||
{
|
||||
foreach (static::$columns as $column => $def) {
|
||||
$alias = $column . '_' . $depth;
|
||||
$alias = $column . '_d' . $depth;
|
||||
|
||||
if (!\array_key_exists($alias, $result)) {
|
||||
continue;
|
||||
|
|
@ -2501,7 +2501,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
|
||||
foreach (static::$hasMany as $member => $def) {
|
||||
$column = $def['mapper']::getColumnByMember($member);
|
||||
$alias = $column . '_' . ($depth - 1);
|
||||
$alias = $column . '_d' . ($depth - 1);
|
||||
|
||||
if (!\array_key_exists($alias, $result) || !isset($def['column'])) {
|
||||
continue;
|
||||
|
|
@ -2606,8 +2606,8 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
) : array
|
||||
{
|
||||
$query ??= self::getQuery(depth: $depth);
|
||||
$query->where(static::$table . '_' . $depth . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), '>', $pivot)
|
||||
->orderBy(static::$table . '_' . $depth . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), $order)
|
||||
$query->where(static::$table . '_d' . $depth . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), '>', $pivot)
|
||||
->orderBy(static::$table . '_d' . $depth . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), $order)
|
||||
->limit($limit);
|
||||
|
||||
$q = $query->toSql();
|
||||
|
|
@ -2645,8 +2645,8 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
) : array
|
||||
{
|
||||
$query ??= self::getQuery(depth: $depth);
|
||||
$query->where(static::$table . '_' . $depth . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), '<', $pivot)
|
||||
->orderBy(static::$table . '_' . $depth . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), $order)
|
||||
$query->where(static::$table . '_d' . $depth . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), '<', $pivot)
|
||||
->orderBy(static::$table . '_d' . $depth . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), $order)
|
||||
->limit($limit);
|
||||
|
||||
return self::getAllByQuery($query, $relations, $depth);
|
||||
|
|
@ -2703,7 +2703,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
}
|
||||
|
||||
foreach ($dbData as $row) {
|
||||
$value = $row[static::$primaryField . '_' . $depth];
|
||||
$value = $row[static::$primaryField . '_d' . $depth];
|
||||
$obj[$value] = self::createBaseModel();
|
||||
self::addInitialized(static::class, $value, $obj[$value], $depth);
|
||||
|
||||
|
|
@ -2725,6 +2725,13 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw data from the last query
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getDataLastQuery() : array
|
||||
{
|
||||
return static::$lastQueryData;
|
||||
|
|
@ -2780,7 +2787,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
}
|
||||
|
||||
foreach ($dbData as $row) {
|
||||
$value = $row[static::$primaryField . '_' . $depth];
|
||||
$value = $row[static::$primaryField . '_d' . $depth];
|
||||
$obj[$value] = self::populateAbstractArray($row, [], $depth);
|
||||
|
||||
self::addInitializedArray(static::class, $value, $obj[$value], $depth);
|
||||
|
|
@ -2920,9 +2927,9 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$query->limit($limit);
|
||||
|
||||
if (!empty(static::$createdAt)) {
|
||||
$query->orderBy(static::$table . '_' . $depth . '.' . static::$columns[static::$createdAt]['name'], 'DESC');
|
||||
$query->orderBy(static::$table . '_d' . $depth . '.' . static::$columns[static::$createdAt]['name'], 'DESC');
|
||||
} else {
|
||||
$query->orderBy(static::$table . '_' . $depth . '.' . static::$columns[static::$primaryField]['name'], 'DESC');
|
||||
$query->orderBy(static::$table . '_d' . $depth . '.' . static::$columns[static::$primaryField]['name'], 'DESC');
|
||||
}
|
||||
|
||||
return self::getAllByQuery($query, $relations, $depth);
|
||||
|
|
@ -2941,7 +2948,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
public static function getByParent(mixed $value, int $depth = 3) : array
|
||||
{
|
||||
$query = self::getQuery();
|
||||
$query->where(static::$table . '_' . $depth . '.' . static::$parent, '=', $value);
|
||||
$query->where(static::$table . '_d' . $depth . '.' . static::$parent, '=', $value);
|
||||
|
||||
return self::getAllByQuery($query, RelationType::ALL, $depth);
|
||||
}
|
||||
|
|
@ -3019,15 +3026,15 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
|
||||
// @todo: check if there are more cases where the relation is already loaded with joins etc.
|
||||
// there can be pseudo has many elements like localizations. They are has manies but these are already loaded with joins!
|
||||
$hasRealHasMany = false;
|
||||
$hasRelHasMany = false;
|
||||
foreach (static::$hasMany as $many) {
|
||||
if (!isset($many['column'])) {
|
||||
$hasRealHasMany = true;
|
||||
$hasRelHasMany = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hasRealHasMany) {
|
||||
if (!$hasRelHasMany) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -3090,49 +3097,49 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$ref = $ref === null || !$hasBy ? static::$primaryField : static::$columns[self::getColumnByMember($ref)]['name'];
|
||||
|
||||
if ($keys !== null && $keys !== false) {
|
||||
$query->where(static::$table . '_' . $depth . '.' . $ref, $comparison, $keys);
|
||||
$query->where(static::$table . '_d' . $depth . '.' . $ref, $comparison, $keys);
|
||||
}
|
||||
} else {
|
||||
if (isset(static::$hasMany[$ref])) {
|
||||
if ($keys !== null && $keys !== false) {
|
||||
$query->where(static::$hasMany[$ref]['table'] . '_' . $depth . '.' . static::$hasMany[$ref]['external'], $comparison, $keys);
|
||||
$query->where(static::$hasMany[$ref]['table'] . '_d' . $depth . '.' . static::$hasMany[$ref]['external'], $comparison, $keys);
|
||||
}
|
||||
|
||||
$query->leftJoin(static::$hasMany[$ref]['table'], static::$hasMany[$ref]['table'] . '_' . $depth);
|
||||
$query->leftJoin(static::$hasMany[$ref]['table'], static::$hasMany[$ref]['table'] . '_d' . $depth);
|
||||
if (static::$hasMany[$ref]['external'] !== null) {
|
||||
$query->on(
|
||||
static::$table . '_' . $depth . '.' . static::$hasMany[$ref][static::$primaryField], '=',
|
||||
static::$hasMany[$ref]['table'] . '_' . $depth . '.' . static::$hasMany[$ref]['self'], 'and',
|
||||
static::$hasMany[$ref]['table'] . '_' . $depth
|
||||
static::$table . '_d' . $depth . '.' . static::$hasMany[$ref][static::$primaryField], '=',
|
||||
static::$hasMany[$ref]['table'] . '_d' . $depth . '.' . static::$hasMany[$ref]['self'], 'and',
|
||||
static::$hasMany[$ref]['table'] . '_d' . $depth
|
||||
);
|
||||
} else {
|
||||
$query->on(
|
||||
static::$table . '_' . $depth . '.' . static::$primaryField, '=',
|
||||
static::$hasMany[$ref]['table'] . '_' . $depth . '.' . static::$hasMany[$ref]['self'], 'and',
|
||||
static::$hasMany[$ref]['table'] . '_' . $depth
|
||||
static::$table . '_d' . $depth . '.' . static::$primaryField, '=',
|
||||
static::$hasMany[$ref]['table'] . '_d' . $depth . '.' . static::$hasMany[$ref]['self'], 'and',
|
||||
static::$hasMany[$ref]['table'] . '_d' . $depth
|
||||
);
|
||||
}
|
||||
} elseif (isset(static::$belongsTo[$ref]) && static::$belongsTo[$ref]['external'] !== null) {
|
||||
if ($keys !== null && $keys !== false) {
|
||||
$query->where(static::$table . '_' . $depth . '.' . $ref, $comparison, $keys);
|
||||
$query->where(static::$table . '_d' . $depth . '.' . $ref, $comparison, $keys);
|
||||
}
|
||||
|
||||
$query->leftJoin(static::$belongsTo[$ref]['mapper']::getTable(), static::$belongsTo[$ref]['mapper']::getTable() . '_' . $depth)
|
||||
$query->leftJoin(static::$belongsTo[$ref]['mapper']::getTable(), static::$belongsTo[$ref]['mapper']::getTable() . '_d' . $depth)
|
||||
->on(
|
||||
static::$table . '_' . $depth . '.' . static::$belongsTo[$ref]['external'], '=',
|
||||
static::$belongsTo[$ref]['mapper']::getTable() . '_' . $depth . '.' . static::$belongsTo[$ref]['mapper']::getPrimaryField() , 'and',
|
||||
static::$belongsTo[$ref]['mapper']::getTable() . '_' . $depth
|
||||
static::$table . '_d' . $depth . '.' . static::$belongsTo[$ref]['external'], '=',
|
||||
static::$belongsTo[$ref]['mapper']::getTable() . '_d' . $depth . '.' . static::$belongsTo[$ref]['mapper']::getPrimaryField() , 'and',
|
||||
static::$belongsTo[$ref]['mapper']::getTable() . '_d' . $depth
|
||||
);
|
||||
} elseif (isset(static::$ownsOne[$ref]) && static::$ownsOne[$ref]['external'] !== null) {
|
||||
if ($keys !== null && $keys !== false) {
|
||||
$query->where(static::$table . '_' . $depth . '.' . $ref, $comparison, $keys);
|
||||
$query->where(static::$table . '_d' . $depth . '.' . $ref, $comparison, $keys);
|
||||
}
|
||||
|
||||
$query->leftJoin(static::$ownsOne[$ref]['mapper']::getTable(), static::$ownsOne[$ref]['mapper']::getTable() . '_' . $depth)
|
||||
$query->leftJoin(static::$ownsOne[$ref]['mapper']::getTable(), static::$ownsOne[$ref]['mapper']::getTable() . '_d' . $depth)
|
||||
->on(
|
||||
static::$table . '_' . $depth . '.' . static::$ownsOne[$ref]['external'], '=',
|
||||
static::$ownsOne[$ref]['mapper']::getTable() . '_' . $depth . '.' . static::$ownsOne[$ref]['mapper']::getPrimaryField() , 'and',
|
||||
static::$ownsOne[$ref]['mapper']::getTable() . '_' . $depth
|
||||
static::$table . '_d' . $depth . '.' . static::$ownsOne[$ref]['external'], '=',
|
||||
static::$ownsOne[$ref]['mapper']::getTable() . '_d' . $depth . '.' . static::$ownsOne[$ref]['mapper']::getPrimaryField() , 'and',
|
||||
static::$ownsOne[$ref]['mapper']::getTable() . '_d' . $depth
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -3140,8 +3147,6 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
try {
|
||||
$results = false;
|
||||
|
||||
$t = $query->toSql();
|
||||
|
||||
$sth = self::$db->con->prepare($query->toSql());
|
||||
if ($sth !== false) {
|
||||
$sth->execute();
|
||||
|
|
@ -3296,12 +3301,12 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
|
||||
foreach ($columns as $key => $values) {
|
||||
if ($values['writeonly'] ?? false === false) {
|
||||
$query->selectAs(static::$table . '_' . $depth . '.' . $key, $key . '_' . $depth);
|
||||
$query->selectAs(static::$table . '_d' . $depth . '.' . $key, $key . '_d' . $depth);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($query->from)) {
|
||||
$query->fromAs(static::$table, static::$table . '_' . $depth);
|
||||
$query->fromAs(static::$table, static::$table . '_d' . $depth);
|
||||
}
|
||||
|
||||
// handle conditional
|
||||
|
|
@ -3315,11 +3320,11 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
}
|
||||
|
||||
if ($condValue['value'] !== null) {
|
||||
$query->andWhere(static::$table . '_' . $depth . '.' . $column, $condValue['comparison'], $condValue['value']);
|
||||
$query->andWhere(static::$table . '_d' . $depth . '.' . $column, $condValue['comparison'], $condValue['value']);
|
||||
}
|
||||
|
||||
if ($condValue['orderBy'] !== null) {
|
||||
$query->orderBy(static::$table . '_' . $depth . '.' . $columns[$condValue['orderBy']], $condValue['sortOrder']);
|
||||
$query->orderBy(static::$table . '_d' . $depth . '.' . $columns[$condValue['orderBy']], $condValue['sortOrder']);
|
||||
}
|
||||
|
||||
if ($condValue['limit'] !== null) {
|
||||
|
|
@ -3334,13 +3339,13 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_' . ($depth - 1))
|
||||
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_d' . ($depth - 1))
|
||||
->on(
|
||||
static::$table . '_' . $depth . '.' . $rel['external'], '=',
|
||||
$rel['mapper']::getTable() . '_' . ($depth - 1) . '.' . (
|
||||
static::$table . '_d' . $depth . '.' . $rel['external'], '=',
|
||||
$rel['mapper']::getTable() . '_d' . ($depth - 1) . '.' . (
|
||||
isset($rel['by']) ? $rel['mapper']::getColumnByMember($rel['by']) : $rel['mapper']::getPrimaryField()
|
||||
), 'and',
|
||||
$rel['mapper']::getTable() . '_' . ($depth - 1)
|
||||
$rel['mapper']::getTable() . '_d' . ($depth - 1)
|
||||
);
|
||||
|
||||
$query = $rel['mapper']::getQuery(
|
||||
|
|
@ -3359,13 +3364,13 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_' . ($depth - 1))
|
||||
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_d' . ($depth - 1))
|
||||
->on(
|
||||
static::$table . '_' . $depth . '.' . $rel['external'], '=',
|
||||
$rel['mapper']::getTable() . '_' . ($depth - 1) . '.' . (
|
||||
static::$table . '_d' . $depth . '.' . $rel['external'], '=',
|
||||
$rel['mapper']::getTable() . '_d' . ($depth - 1) . '.' . (
|
||||
isset($rel['by']) ? $rel['mapper']::getColumnByMember($rel['by']) : $rel['mapper']::getPrimaryField()
|
||||
), 'and',
|
||||
$rel['mapper']::getTable() . '_' . ($depth - 1)
|
||||
$rel['mapper']::getTable() . '_d' . ($depth - 1)
|
||||
);
|
||||
|
||||
$query = $rel['mapper']::getQuery(
|
||||
|
|
@ -3388,13 +3393,13 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
}
|
||||
|
||||
// todo: handle self and self === null
|
||||
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_' . ($depth - 1))
|
||||
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_d' . ($depth - 1))
|
||||
->on(
|
||||
static::$table . '_' . $depth . '.' . ($rel['external'] ?? static::$primaryField), '=',
|
||||
$rel['mapper']::getTable() . '_' . ($depth - 1) . '.' . (
|
||||
static::$table . '_d' . $depth . '.' . ($rel['external'] ?? static::$primaryField), '=',
|
||||
$rel['mapper']::getTable() . '_d' . ($depth - 1) . '.' . (
|
||||
isset($rel['by']) ? $rel['mapper']::getColumnByMember($rel['by']) : $rel['self']
|
||||
), 'and',
|
||||
$rel['mapper']::getTable() . '_' . ($depth - 1)
|
||||
$rel['mapper']::getTable() . '_d' . ($depth - 1)
|
||||
);
|
||||
|
||||
$query = $rel['mapper']::getQuery(
|
||||
|
|
|
|||
|
|
@ -1136,166 +1136,166 @@ class Builder extends BuilderAbstract
|
|||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function leftJoin(string | self $column, string $alias = null) : self
|
||||
public function leftJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::LEFT_JOIN, $alias);
|
||||
return $this->join($table, JoinType::LEFT_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function leftOuterJoin(string | self $column, string $alias = null) : self
|
||||
public function leftOuterJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::LEFT_OUTER_JOIN, $alias);
|
||||
return $this->join($table, JoinType::LEFT_OUTER_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function leftInnerJoin(string | self $column, string $alias = null) : self
|
||||
public function leftInnerJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::LEFT_INNER_JOIN, $alias);
|
||||
return $this->join($table, JoinType::LEFT_INNER_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function rightJoin(string | self $column, string $alias = null) : self
|
||||
public function rightJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::RIGHT_JOIN, $alias);
|
||||
return $this->join($table, JoinType::RIGHT_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function rightOuterJoin(string | self $column, string $alias = null) : self
|
||||
public function rightOuterJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::RIGHT_OUTER_JOIN, $alias);
|
||||
return $this->join($table, JoinType::RIGHT_OUTER_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function rightInnerJoin(string | self $column, string $alias = null) : self
|
||||
public function rightInnerJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::RIGHT_INNER_JOIN, $alias);
|
||||
return $this->join($table, JoinType::RIGHT_INNER_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function outerJoin(string | self $column, string $alias = null) : self
|
||||
public function outerJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::OUTER_JOIN, $alias);
|
||||
return $this->join($table, JoinType::OUTER_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function innerJoin(string | self $column, string $alias = null) : self
|
||||
public function innerJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::INNER_JOIN, $alias);
|
||||
return $this->join($table, JoinType::INNER_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function crossJoin(string | self $column, string $alias = null) : self
|
||||
public function crossJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::CROSS_JOIN, $alias);
|
||||
return $this->join($table, JoinType::CROSS_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function fullJoin(string | self $column, string $alias = null) : self
|
||||
public function fullJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::FULL_JOIN, $alias);
|
||||
return $this->join($table, JoinType::FULL_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join.
|
||||
*
|
||||
* @param string|self $column Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
* @param string|self $table Join query
|
||||
* @param null|string $alias Alias name (empty = none)
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function fullOuterJoin(string | self $column, string $alias = null) : self
|
||||
public function fullOuterJoin(string | self $table, string $alias = null) : self
|
||||
{
|
||||
return $this->join($column, JoinType::FULL_OUTER_JOIN, $alias);
|
||||
return $this->join($table, JoinType::FULL_OUTER_JOIN, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1416,7 +1416,6 @@ class Builder extends BuilderAbstract
|
|||
public function execute() : mixed
|
||||
{
|
||||
try {
|
||||
$t = $this->toSql();
|
||||
$sth = $this->connection->con->prepare($this->toSql());
|
||||
|
||||
foreach ($this->binds as $key => $bind) {
|
||||
|
|
@ -1429,6 +1428,8 @@ class Builder extends BuilderAbstract
|
|||
} catch (\Throwable $t) {
|
||||
\var_dump($t->getMessage());
|
||||
\var_dump($this->toSql());
|
||||
|
||||
$sth = null;
|
||||
}
|
||||
|
||||
return $sth;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
|
|||
/**
|
||||
* Generate response based on header.
|
||||
*
|
||||
* @param mixed $data Data passt to render function. (0 => bool: $optimize)
|
||||
* @param mixed ...$data Data passt to render function. (0 => bool: $optimize)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
],
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": ">=9.4",
|
||||
"friendsofphp/php-cs-fixer": ">=2.18",
|
||||
"friendsofphp/php-cs-fixer": ">=3.0",
|
||||
"squizlabs/php_codesniffer": ">=3.5",
|
||||
"phpmd/phpmd": ">=2.9",
|
||||
"phpstan/phpstan": ">=0.12.58",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user