//项目运行
php app/console server:run
//创建实体 php app/console doctrine:generate:entity
bundle名称:实体名称 例如:SymfonySampleBundle:Article
//实体添加ORM和Assert use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert;
//同步数据库 php app/console doctrine:schema:update --force
//自动创建增删该查 php app/console generate:doctrine:crud
//关联关系创建: 对应的yml中添加多对一的关系 manyToOne: category: targetEntity: PhotoCategory--一端实体名称 inversedBy: photos joinColumn: name: photocategory_id--多端对应的实体字段 referencedColumnName: id
实体中ORM /** * @ORM\ManyToOne(targetEntity="PhotoCategory", inversedBy="photos") * @ORM\JoinColumn(name="photocategory_id", referencedColumnName="id") */ private $category;
//生成geter,seter php app/console doctrine:generate:entities AcmeStoreBundle
微信公众号:
|
请发表评论