- Work done on many-to-many relations - code must still be refactored out of the EntityTrait.
- Fixed Entity::field("propertyname") function to look for name into @Field() annotation and returns it if it exists.
- A lot of bug fixes made into SQL fragments.
This commit is contained in:
1 parent
6e84fc7195
commit
c64c7778bd
20 files changed
+220
-105
No files matched your search
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace Ulmus\Common;
|
||||
|
||||
use Ulmus\Ulmus;
|
||||
use Ulmus\Ulmus,
|
||||
Ulmus\Annotation\Property\Field;
|
||||
|
||||
class EntityField
|
||||
{
|
||||
@@ -14,20 +15,19 @@ class EntityField
|
||||
|
||||
protected EntityResolver $entityResolver;
|
||||
|
||||
public function __construct(string $entityClass, string $name, string $alias)
|
||||
public function __construct(string $entityClass, string $name, string $alias, EntityResolver $resolver)
|
||||
{
|
||||
$this->entityClass = $entityClass;
|
||||
$this->name = $name;
|
||||
$this->alias = $alias;
|
||||
$this->entityResolver = Ulmus::resolveEntity(static::class);
|
||||
}
|
||||
$this->entityResolver = $resolver;
|
||||
}
|
||||
|
||||
public function name($useAlias = true) : string
|
||||
{
|
||||
# Must use REFLECTION before throwing this value.
|
||||
# Should first check if it's a relation field, and if it is,
|
||||
# it's real key must be returned (PK usually)
|
||||
return $useAlias ? "{$this->alias}.\"{$this->name}\"" : "\"{$this->name}\"";
|
||||
$name = $this->entityResolver->searchFieldAnnotation($this->name, new Field() )->name ?? $this->name;
|
||||
|
||||
return $useAlias ? "{$this->alias}.\"{$name}\"" : "\"{$name}\"";
|
||||
}
|
||||
|
||||
public static function isScalarType($type) : bool
|
||||
|
||||
@@ -94,9 +94,9 @@ class EntityResolver {
|
||||
return [];
|
||||
}
|
||||
catch(\Throwable $e) {
|
||||
if ( $throwException) {
|
||||
# if ( $throwException) {
|
||||
throw new \InvalidArgumentException("Can't find entity relation's column named `$name` from entity {$this->entityClass}");
|
||||
}
|
||||
# }
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -16,6 +16,7 @@ class PdoObject extends PDO {
|
||||
return $statement;
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
debogueur($sql, $parameters);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -26,6 +27,7 @@ class PdoObject extends PDO {
|
||||
return $this->execute($statement, $parameters, true);
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
debogueur($sql, $parameters);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -41,7 +43,7 @@ class PdoObject extends PDO {
|
||||
if (empty($parameters) ? $statement->execute() : $statement->execute($parameters)) {
|
||||
$statement->lastInsertId = $this->lastInsertId();
|
||||
|
||||
if ($commit) {
|
||||
if ( $commit ) {
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user