From 9272af316b75683b7bc987b79499e6bf0a085ea4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 20 Feb 2021 21:18:12 +0100 Subject: [PATCH] fix formatting/debugging --- DataStorage/Database/DataMapperAbstract.php | 20 +++++++++++++++----- DataStorage/Database/Query/Builder.php | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 3ca6d8743..82e3e5f1b 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -2563,6 +2563,7 @@ class DataMapperAbstract implements DataMapperInterface * @param string $order Order of the elements * @param int $relations Load relations * @param int $depth Relation depth + * @param Builder $query Query * * @return array * @@ -2574,10 +2575,11 @@ class DataMapperAbstract implements DataMapperInterface int $limit = 50, string $order = 'ASC', int $relations = RelationType::ALL, - int $depth = 3 + int $depth = 3, + Builder $query = null ) : array { - $query = self::getQuery(depth: $depth); + $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) ->limit($limit); @@ -2594,6 +2596,7 @@ class DataMapperAbstract implements DataMapperInterface * @param string $order Order of the elements * @param int $relations Load relations * @param int $depth Relation depth + * @param Builder $query Query * * @return array * @@ -2609,10 +2612,11 @@ class DataMapperAbstract implements DataMapperInterface int $limit = 50, string $order = 'ASC', int $relations = RelationType::ALL, - int $depth = 3 + int $depth = 3, + Builder $query = null ) : array { - $query = self::getQuery(); + $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) ->limit($limit); @@ -2633,7 +2637,13 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - public static function get(mixed $primaryKey, int $relations = RelationType::ALL, int $depth = 3, string $ref = null, Builder $query = null) : mixed + public static function get( + mixed $primaryKey, + int $relations = RelationType::ALL, + int $depth = 3, + string $ref = null, + Builder $query = null + ) : mixed { if ($depth < 1) { return self::createNullModel($primaryKey); diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index c82b18ced..b481edf31 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -1413,6 +1413,7 @@ class Builder extends BuilderAbstract $sth->execute(); } catch (\Throwable $t) { + \var_dump($t->getMessage()); \var_dump($this->toSql()); }