Mudanças entre as edições de "Gerando getters and setters de uma entity do Doctrine"
De Basef
(Criou página com 'Supondo que temos a entity Product, já criada, em src/AppBundle/Entity/Product.php, com o conteúdo: <source lang="php"> <?php namespace AppBundle\Entity; use Doctrine\ORM...') |
|||
Linha 44: | Linha 44: | ||
</source> | </source> | ||
+ | |||
+ | Note que é muito importante o uso de: | ||
+ | <source lang="php"> | ||
+ | use Doctrine\ORM\Mapping as ORM; | ||
+ | </source> | ||
[[Category:Symfony]] | [[Category:Symfony]] |
Edição atual tal como às 20h33min de 2 de maio de 2016
Supondo que temos a entity Product, já criada, em src/AppBundle/Entity/Product.php, com o conteúdo:
<?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="product") */ class Product { /** * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\Column(type="string", length=100) */ private $name; /** * @ORM\Column(type="decimal", scale=2) */ private $price; /** * @ORM\Column(type="text") */ private $description; }
Para gerar os getters e setters dos atributos:
php bin/console doctrine:generate:entities AppBundle/Entity/Product
Note que é muito importante o uso de:
use Doctrine\ORM\Mapping as ORM;