所以我已经完成了所有设置,但我仍然得到:
没有为实体指定标识符/主键 " Bisna \应用程序\实体\公司&#34 ;.每个实体必须有一个 标识符/主键。
实体:
<?php
namespace Bisna\Application\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Company
*
* @ORM\Table(name="companies")
* @ORM\Entity
*/
class Company{
/**
* @var integer $id
*
* @ORM\Id
* ORM\Column(name="id", type="integer", nullable=false)
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var string $industry
*
* @ORM\ManyToOne(targetEntity="CompanyIndustry", inversedBy="company_industry")
* @ORM\JoinColumn(name="industry_id", referencedColumnName="id", nullable=false)
*/
protected $industry;
/**
* @var string $billingAddress
*
* @ORM\ManyToOne(targetEntity="BillingAddress", inversedBy="billing_addresses")
* @ORM\JoinColumn(name="billing_address_id", referencedColumnName="id", nullable=false)
*/
protected $billingAddress;
/**
* @var string $companyName
*
* @ORM\Column(name="companyName", type="string", length=255, nullable=false)
*/
protected $companyName;
/**
* @var string $website
*
* @ORM\Column(name="website", type="string", length=255, nullable=true)
*/
protected $website;
/**
* @var string $address
*
* @ORM\Column(name="address", type="string", length=255, nullable=true)
*/
protected $address;
/**
* @var string $employeesNumber
*
* @ORM\Column(name="employees_number", type="string", length=255, nullable=true)
*/
protected $employeesNumber;
/**
* @var string $streetNumber
*
* @ORM\Column(name="street_number", type="string", length=255, nullable=true)
*/
protected $streetNumber;
/**
* @var string $street
*
* @ORM\Column(name="street", type="string", length=255, nullable=true)
*/
protected $street;
/**
* @var string $city
*
* @ORM\Column(name="city", type="string", length=255, nullable=false)
*/
protected $city;
/**
* @var string $cityVarname
*
* @ORM\Column(name="city_varname", type="string", length=255, nullable=true)
*/
protected $cityVarname;
/**
* @var string $state
*
* @ORM\Column(name="state", type="string", length=255, nullable=true)
*/
protected $state;
/**
* @var string $stateVarname
*
* @ORM\Column(name="state_varname", type="string", length=255, nullable=true)
*/
protected $stateVarname;
/**
* @var string $stateCode
*
* @ORM\Column(name="state_code", type="string", length=255, nullable=true)
*/
protected $stateCode;
/**
* @var string $postalCode
*
* @ORM\Column(name="postal_code", type="string", length=255, nullable=true)
*/
protected $postalCode;
/**
* @var string $country
*
* @ORM\Column(name="country", type="string", length=255, nullable=true)
*/
protected $country;
/**
* @var string $countryVarname
*
* @ORM\Column(name="country_varname", type="string", length=255, nullable=true)
*/
protected $countryVarname;
/**
* @var string $countryCode
*
* @ORM\Column(name="country_code", type="string", length=255, nullable=true)
*/
protected $countryCode;
/**
* @var string $latitude
*
* @ORM\Column(name="latitude", type="string", length=255, nullable=true)
*/
protected $latitude;
/**
* @var string $longitude
*
* @ORM\Column(name="longitude", type="string", length=255, nullable=true)
*/
protected $longitude;
/**
* @var string $email
*
* @ORM\Column(name="email", type="string", length=255, nullable=true)
*/
protected $email;
/**
* @var string $password
*
* @ORM\Column(name="password", type="string", length=255, nullable=true)
*/
protected $password;
/**
* @var string $firstname
*
* @ORM\Column(name="firstName", type="string", length=255, nullable=false)
*/
protected $firstname;
/**
* @var string $lastname
*
* @ORM\Column(name="lastName", type="string", length=255, nullable=false)
*/
protected $lastname;
/**
* @var Collection $jobs
*
* @ORM\OneToMany(targetEntity="CompanyJob", mappedBy="company", cascade={"persist", "remove"})
* @ORM\OrderBy({"created" = "ASC"})
*/
protected $jobs;
/**
* @var string $activationCode
*
* @ORM\Column(name="activationCode", type="string", length=255, nullable=true)
*/
protected $activationCode;
/**
* @var string $resetPasswordCode
*
* @ORM\Column(name="resetPasswordCode", type="string", length=255, nullable=true)
*/
protected $resetPasswordCode;
/**
* @var string $status ['activation', 'active', 'inactive']
*
* @ORM\Column(name="status", type="string", length=255, nullable=false)
*/
protected $status;
/**
* @var datetime $created
*
* @ORM\Column(name="created", type="datetime", nullable=false)
*/
protected $created;
/* .... */
}
我还没有制作表格,但是,我仍然不明白为什么我会收到这个错误,因为我拥有一切。有什么想法吗?
答案 0 :(得分:0)
也许是因为您在@
财产的@ORM\Column
注释之前错过了$id
?
您应该考虑使用Yaml学说映射。这是将实体与数据库列定义分开的好方法。此外,您的IDE应该验证Yaml内容,而它可能不会将PHP注释验证为PHP代码。