@@ -130,12 +130,12 @@ in the database. This is usually done with annotations:
130130 private $id;
131131
132132 /**
133- * @ORM\Column(type="string", length=100, nullable=false )
133+ * @ORM\Column(type="string", length=100)
134134 */
135135 private $name;
136136
137137 /**
138- * @ORM\Column(type="decimal", scale=2, nullable=false )
138+ * @ORM\Column(type="decimal", scale=2, nullable=true )
139139 */
140140 private $price;
141141 }
@@ -153,11 +153,10 @@ in the database. This is usually done with annotations:
153153name :
154154type :string
155155length :100
156- nullable :false
157156price :
158157type :decimal
159158scale :2
160- nullable :false
159+ nullable :true
161160
162161 ..code-block ::xml
163162
@@ -172,8 +171,8 @@ in the database. This is usually done with annotations:
172171 <id name =" id" type =" integer" >
173172 <generator strategy =" AUTO" />
174173 </id >
175- <field name =" name" type =" string" length =" 100" nullable = " false " />
176- <field name =" price" type =" decimal" scale =" 2" nullable =" false " />
174+ <field name =" name" type =" string" length =" 100" />
175+ <field name =" price" type =" decimal" scale =" 2" nullable =" true " />
177176 </entity >
178177 </doctrine-mapping >
179178
@@ -455,8 +454,8 @@ Once you have a repository object, you have many helper methods::
455454
456455 // query for multiple Product objects matching the name, ordered by price
457456 $products = $repository->findBy(
458- array( 'name' => 'Keyboard') ,
459- array( 'price' => 'ASC')
457+ [ 'name' => 'Keyboard'] ,
458+ [ 'price' => 'ASC']
460459 );
461460
462461 // find *all* Product objects
@@ -584,6 +583,10 @@ But what if you need a more complex query? When you generated your entity with
584583
585584 class ProductRepository extends ServiceEntityRepository
586585 {
586+ public function __construct(RegistryInterface $registry)
587+ {
588+ parent::__construct($registry, Product::class);
589+ }
587590 }
588591
589592When you fetch your repository (i.e. ``->getRepository(Product::class) ``, it is
@@ -598,6 +601,8 @@ a new method for this to your repository::
598601 // ...
599602 class ProductRepository extends ServiceEntityRepository
600603 {
604+ // ...
605+
601606 /**
602607 * @param $price
603608 * @return Product[]
@@ -672,7 +677,7 @@ Or directly with SQL if you need to::
672677 ORDER BY p.price ASC
673678 ';
674679 $stmt = $conn->prepare($sql);
675- $stmt->execute(array( 'price' => 10) );
680+ $stmt->execute([ 'price' => 10] );
676681
677682 // returns an array of arrays (i.e. a raw data set)
678683 return $stmt->fetchAll();