diff --git a/src/Annotation/Property/Field/Id.php b/src/Annotation/Property/Field/Id.php index 931b0ae..277373c 100644 --- a/src/Annotation/Property/Field/Id.php +++ b/src/Annotation/Property/Field/Id.php @@ -11,7 +11,7 @@ class Id extends \Ulmus\Annotation\Property\Field { $this->attributes['primary_key'] = true; $this->attributes['auto_increment'] = true; - parent::__construct('int'); + parent::__construct('bigint'); } } diff --git a/src/EntityCollection.php b/src/EntityCollection.php index 5f94cfe..aad784f 100644 --- a/src/EntityCollection.php +++ b/src/EntityCollection.php @@ -221,19 +221,35 @@ class EntityCollection extends \ArrayObject { public function fromArray(array $datasets, ? string /*stringable*/ $entityClass = null) : self { - if ( ! ($this->entityClass || $entityClass) ) { - throw new \Exception("An entity class name must be provided to be instanciated and populated before insertion into this collection."); - } - - $className = $entityClass ?: $this->entityClass; - + foreach($datasets as $dataset) { - $this->append( (new $className() )->fromArray($dataset) ); + $this->append( $this->arrayToEntity($dataset, $entityClass) ); } return $this; } + public function arrayToEntity(array $dataset, ? string /*stringable*/ $entityClass = null) : object + { + if ( ! ($this->entityClass || $entityClass) ) { + throw new \Exception("An entity class name must be provided to be instanciated and populated before insertion into this collection."); + } + + $className = $this->entityClass; + + return ( new $className() )->fromArray($dataset); + } + + public function append($value) : void + { + if ( is_array($value) ) { + $this->append( $this->arrayToEntity($value) ); + } + else { + parent::append($value); + } + } + public function mergeWith( /*array|EntityCollection*/ $datasets ) : self { if ( is_object($datasets) ) { diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 5ce92a9..2d0bb8e 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -64,11 +64,11 @@ class QueryBuilder { if ( null === $this->getFragment(Query\Insert::class) ) { if ( $schema ) { - $table = "\"$schema\".$table"; + $table = "$schema.$table"; } - + if ( $database ) { - $table = "\"$database\".$table"; + $table = "$database.$table"; } $insert = new Query\Insert(); @@ -327,11 +327,11 @@ class QueryBuilder { if ( null === $this->getFragment(Query\Create::class) ) { if ( $schema ) { - $table = "\"$schema\".$table"; + $table = "$schema.$table"; } - + if ( $database ) { - $table = "\"$database\".$table"; + $table = "$database.$table"; } $create = new Query\Create();