@@ -32,9 +32,9 @@ and year of production as primary keys:
32
32
class Car
33
33
{
34
34
public function __construct(
35
- #[Id, Column(type: 'string') ]
35
+ #[Id, Column]
36
36
private string $name,
37
- #[Id, Column(type: 'integer') ]
37
+ #[Id, Column]
38
38
private int $year,
39
39
) {
40
40
}
@@ -131,7 +131,7 @@ And for querying you can use arrays to both DQL and EntityRepositories:
131
131
132
132
$dql = "SELECT c FROM VehicleCatalogue\Model\Car c WHERE c.id = ?1";
133
133
$audi = $em->createQuery($dql)
134
- ->setParameter(1, array( "name" => "Audi A8", "year" => 2010) )
134
+ ->setParameter(1, [ "name" => "Audi A8", "year" => 2010] )
135
135
->getSingleResult();
136
136
137
137
You can also use this entity in associations. Doctrine will then generate two foreign keys one for ``name ``
@@ -179,9 +179,9 @@ We keep up the example of an Article with arbitrary attributes, the mapping look
179
179
#[Entity]
180
180
class Article
181
181
{
182
- #[Id, Column(type: 'integer') , GeneratedValue]
182
+ #[Id, Column, GeneratedValue]
183
183
private int|null $id = null;
184
- #[Column(type: 'string') ]
184
+ #[Column]
185
185
private string $title;
186
186
187
187
/** @var ArrayCollection<string, ArticleAttribute> */
@@ -200,10 +200,10 @@ We keep up the example of an Article with arbitrary attributes, the mapping look
200
200
#[Id, ManyToOne(targetEntity: Article::class, inversedBy: 'attributes')]
201
201
private Article $article;
202
202
203
- #[Id, Column(type: 'string') ]
203
+ #[Id, Column]
204
204
private string $attribute;
205
205
206
- #[Column(type: 'string') ]
206
+ #[Column]
207
207
private string $value;
208
208
209
209
public function __construct(string $name, string $value, Article $article)
@@ -317,7 +317,7 @@ One good example for this is a user-address relationship:
317
317
#[Entity]
318
318
class User
319
319
{
320
- #[Id, Column(type: 'integer') , GeneratedValue]
320
+ #[Id, Column, GeneratedValue]
321
321
private int|null $id = null;
322
322
}
323
323
@@ -365,18 +365,18 @@ of products purchased and maybe even the current price.
365
365
#[Entity]
366
366
class Order
367
367
{
368
- #[Id, Column(type: 'integer') , GeneratedValue]
368
+ #[Id, Column, GeneratedValue]
369
369
private int|null $id = null;
370
370
371
371
/** @var ArrayCollection<int , OrderItem > */
372
372
#[OneToMany(targetEntity: OrderItem::class, mappedBy: 'order')]
373
373
private Collection $items;
374
374
375
- #[Column(type: 'boolean') ]
375
+ #[Column]
376
376
private bool $paid = false;
377
- #[Column(type: 'boolean') ]
377
+ #[Column]
378
378
private bool $shipped = false;
379
- #[Column(type: 'datetime') ]
379
+ #[Column]
380
380
private DateTime $created;
381
381
382
382
public function __construct(
@@ -391,16 +391,16 @@ of products purchased and maybe even the current price.
391
391
#[Entity]
392
392
class Product
393
393
{
394
- #[Id, Column(type: 'integer') , GeneratedValue]
394
+ #[Id, Column, GeneratedValue]
395
395
private int|null $id = null;
396
396
397
- #[Column(type: 'string') ]
397
+ #[Column]
398
398
private string $name;
399
399
400
- #[Column(type: 'decimal') ]
401
- private float $currentPrice;
400
+ #[Column]
401
+ private int $currentPrice;
402
402
403
- public function getCurrentPrice(): float
403
+ public function getCurrentPrice(): int
404
404
{
405
405
return $this->currentPrice;
406
406
}
@@ -415,11 +415,11 @@ of products purchased and maybe even the current price.
415
415
#[Id, ManyToOne(targetEntity: Product::class)]
416
416
private Product|null $product = null;
417
417
418
- #[Column(type: 'integer') ]
418
+ #[Column]
419
419
private int $amount = 1;
420
420
421
- #[Column(type: 'decimal') ]
422
- private float $offeredPrice;
421
+ #[Column]
422
+ private int $offeredPrice;
423
423
424
424
public function __construct(Order $order, Product $product, int $amount = 1)
425
425
{
0 commit comments