1
我試圖用更新我的教義模式:主義組合鍵投擲的錯誤
php vendor/bin/doctrine orm:schema-tool:update
但我收到錯誤消息:
[Doctrine\ORM\Mapping\MappingException]
Single id is not allowed on composite primary key in entity entities\Events
事件實體看起來是這樣的:
<?php
// entities/Events.php
namespace entities;
use Entities\Enities;
use Doctrine\ORM\Mapping;
use Doctrine\ORM\Mapping\Table;
/**
* @Entity
* @Table(name="development.events")
**/
class Events extends Entities {
/**
* @var integer
*
* @Id
* @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
protected $event_id;
/**
* @var integer
*
* @Id
* @Column(name="app_id", type="integer")
*/
protected $app_id = 0;
/**
* @var string
* @Column(type="string", length=64)
*/
protected $post_title;
public function __construct($event, $app){
$this->event_id = $event;
$this->app_id= $app;
}
}
根據文檔,本機支持組合鍵。 http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html我做錯了什麼?
它的工作,但這是否意味着,爲了這個價值,我必須以編程方式,偉大和ID或UUID而不是讓數據庫創建自動遞增值? –
是的,或者你可以使用[#identity-through-foreign-entities](http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html#身份通過外國實體),但我真的不明白你的用例是什麼,你想達到什麼目的?不推薦使用複合鍵,你應該儘可能避免使用。 – 1ed