Php 原则2:使用表模式更新实体
我在zend框架2中使用了条令2。要使用数据库表从现有实体生成方法,使用的控制台命令为:Php 原则2:使用表模式更新实体,php,doctrine-orm,zend-framework2,Php,Doctrine Orm,Zend Framework2,我在zend框架2中使用了条令2。要使用数据库表从现有实体生成方法,使用的控制台命令为: php doctrine-module orm:generate-entities --generate-annotations="true" --generate-methods="true" module 我有两个名称空间博客和位置 我的问题是: 1. When I run above code, only blog entities get updated. I want to know why
php doctrine-module orm:generate-entities --generate-annotations="true" --generate-methods="true" module
我有两个名称空间博客和位置
我的问题是:
1. When I run above code, only blog entities get updated. I want to know why it is behaving like this?
2. If I want to update only a specific entity, how can i do it?
博客有两个实体:Post和cateogray
Category.php
<?php
namespace Blog\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
/**
* Category
*
* @ORM\Table(name="Categories")
* @ORM\Entity
*/
class Category implements InputFilterAwareInterface
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", nullable=false)
*/
private $name;
protected $inputFilter;
/**
* Get Id
*
* @param integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Category
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
}
该位置包含Country.php
<?php
namespace Country\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Country
*
* @ORM\Table(name="countries")
* @ORM\Entity
*/
class Country
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=55, nullable=false)
*/
private $name;
}
当然,每个人都需要ZF2上的一个函数,这样就有可能生成单个实体。但那些时候,你不能仅仅靠一个模块来完成。当你试图在交响乐中运用教义时,这是可以接受的。我使用的doctrine2与zf2具有相同的问题
我创建了一个我调用的PHP脚本
Script to Create a Single Entity:
Choose Entity Name.
Generate All Entities on a Temp Folder.
Exclude All non-needed entities from folder.
Copy Single Entity to "src/$module/Entity" Folder.
是一个我必须让它根据您的需要工作的hack属性。使用--filter选项来完成此操作。
php条令模块orm:生成实体--filter=“Post”…您可以发布博客和位置实体映射吗?
Script to Create a Single Entity:
Choose Entity Name.
Generate All Entities on a Temp Folder.
Exclude All non-needed entities from folder.
Copy Single Entity to "src/$module/Entity" Folder.