2011-06-05 8 views
6

मैं Doctrine2 के साथ अपने Symfony2 एप्लिकेशन के लिए कई से अधिक संबंध बनाने का प्रयास करता हूं। मैं इस त्रुटि मिलती है और मैं नहीं जानता कि क्यों:OneToMany/ManyToOne SchemaException

app/console doctrine:schema:create 
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0 
ATTENTION: This operation should not be executed in an production enviroment. 


    [Doctrine\DBAL\Schema\SchemaException] 
    There is no column with name 'activityGroup' on table 'activity'. 

उन दो वर्ग हैं: http://pastebin.com/Ev7Rwgxr

मैं वहाँ वास्तव में activityGroup गतिविधि वर्ग पर है लगता है ... कि त्रुटि करने की कोशिश तो क्या करता है कहते हैं?

धन्यवाद!

उत्तर

8

मुझे मिल गया ...

uniqueconstraints असली db फ़ील्ड नाम जो activityGroup_id और न सिर्फ activityGroup है उम्मीद है।

कोई भी यह सुनिश्चित कर सकता है कि डीबी में क्षेत्र को कॉलकॉलम प्रदान करके क्या कहा जाता है।

तो, एक स्मार्ट समाधान है:

/** 
    * @ORM\Entity 
    * @ORM\Table(name="activity", 
    *  uniqueConstraints={ 
    *   @ORM\UniqueConstraint(name="name_idx", columns={"activity_group_id", "name"}), 
    *   @ORM\UniqueConstraint(name="sort_idx", columns={"activity_group_id", "sort_id"}) 
    *  } 
    *) 
    */ 
    class Activity 
    { 
     // ... 

     /** 
     * @ORM\ManyToOne(targetEntity="SeduceMe\SiteBundle\Entity\ActivityGroup", inversedBy="activities") 
     * @ORM\JoinColumn(name="activity_group_id", referencedColumnName="id") 
     */ 

     protected $activityGroup; 
     //... 
    }