2010-08-18 51 views
0

對於使用關係的schema.yml,您是否必須使用InnoDB?這是我的模式:使用Doctrine和MySQL的Symfony

BuybackStatus: 
    connection: doctrine 
    tableName: buyback_statuses 
    columns: 
    id: 
     type: integer(4) 
     fixed: false 
     unsigned: true 
     primary: true 
     autoincrement: true 
    label: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    relations: 
    BuybackStatus: 
     local: id 
     foreign: status_id 
     type: one 
Country: 
    connection: doctrine 
    tableName: countries 
    columns: 
    id: 
     type: integer(4) 
     fixed: false 
     unsigned: true 
     primary: true 
     autoincrement: true 
    label: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    code: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    relations: 
    StateCountry: 
     local: id 
     foreign: state_id 
     type: one 
    UserCountry: 
     local: id 
     foreign: state_id 
     type: one 
Manufacture: 
    connection: doctrine 
    tableName: manufactures 
    columns: 
    id: 
     type: integer(4) 
     fixed: false 
     unsigned: true 
     primary: true 
     autoincrement: true 
    label: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    relations: 
    PhoneModelManufacture: 
     local: id 
     foreign: manufacture_id 
     type: one 
PhoneModel: 
    connection: doctrine 
    tableName: phone_models 
    columns: 
    id: 
     type: integer(4) 
     fixed: false 
     unsigned: true 
     primary: true 
     autoincrement: true 
    manufacture_id: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    label: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    buyback_price: 
     type: 'decimal(6, 2)' 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    relations: 
    PhoneModelManufacture: 
     onDelete: CASCADE 
     local: manufacture_id 
     foreign: id 
    BuybackModel: 
     local: id 
     foreign: model_id 
     type: one 
Quality: 
    connection: doctrine 
    tableName: qualities 
    columns: 
    id: 
     type: integer(4) 
     fixed: false 
     unsigned: true 
     primary: true 
     autoincrement: true 
    label: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    percent: 
     type: 'decimal(6, 2)' 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    relations: 
    BuybackQuality: 
     local: id 
     foreign: quality_id 
     type: one 
State: 
    connection: doctrine 
    tableName: states 
    columns: 
    id: 
     type: integer(4) 
     fixed: false 
     unsigned: true 
     primary: true 
     autoincrement: true 
    label: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    code: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    country_id: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    relations: 
    StateCountry: 
     onDelete: CASCADE 
     local: country_id 
     foreign: id 
     foreignAlias: StateCountries 
    UserState: 
     local: id 
     foreign: state_id 
     type: one 
User: 
    connection: doctrine 
    tableName: users 
    columns: 
    id: 
     type: integer(4) 
     fixed: false 
     unsigned: true 
     primary: true 
     autoincrement: true 
    fname: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    lname: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    phone: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    email: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    password: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    street: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    city: 
     type: string() 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    state_id: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    country_id: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    relations: 
    UserState: 
     onDelete: CASCADE 
     local: state_id 
     foreign: id 
     type: one 
    UserCountry: 
     onDelete: CASCADE 
     local: country_id 
     foreign: id 
     type: one 
    BuybackUser: 
     local: id 
     foreign: user_id 
     type: many 
BuybackPhone: 
    connection: doctrine 
    tableName: buyback_phones 
    columns: 
    id: 
     type: integer(4) 
     fixed: false 
     unsigned: true 
     primary: true 
     autoincrement: true 
    user_id: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    model_id: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    quality_id: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    buyback_status_id: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    amount_quoted: 
     type: 'decimal(6, 2)' 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    amount_paid: 
     type: 'decimal(6, 2)' 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    makes_calls: 
     type: integer(1) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    water_damage: 
     type: integer(1) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    has_charger: 
     type: integer(1) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    has_battery: 
     type: integer(1) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    relations: 
    BuybackUser: 
     onDelete: CASCADE 
     local: user_id 
     foreign: id 
     type: one 
    BuybackModel: 
     onDelete: CASCADE 
     local: model_id 
     foreign: id 
     type: one 
    BuybackQuality: 
     onDelete: CASCADE 
     local: quality_id 
     foreign: id 
     type: one 
    BuybackStatus: 
     onDelete: CASCADE 
     local: buyback_status_id 
     foreign: id 
     type: one 

但是數據庫是MyISAM。所以,當我運行:php symfony doctrine:build --model我得到這些一堆:

Notice: Undefined index: class in /home/kacie/cellphone/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Import/Builder.php on line 672 

我是全新的,以Symfony的,所以我可以搞砸了的模式,請檢查。

下面是它實際負載:

>> tokens /home/kacie/cellphone/lib/model/doctrine/PhoneModel.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/PhoneModelTable.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/BuybackStatus.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/BuybackPhoneTable.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/Manufacture.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/CountryTable.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/Country.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/ManufactureTable.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/UserTable.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/Quality.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/BuybackPhone.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/BuybackStatusTable.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/User.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/State.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/StateTable.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/QualityTable.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseState.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseBuybackStatus.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseUser.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseBuybackPhone.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseManufacture.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BasePhoneModel.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseQuality.class.php 
>> tokens /home/kacie/cellphone/lib/model/doctrine/base/BaseCountry.class.php 
>> autoload Resetting application autoloaders 
>> file-  /home/kacie/cellphone/cache/frontend/prod/config/config_autoload.yml.php 

不過在此之前有一堆未定義指數告示的,我不想再往前走,我現在已經報廢申請幾次並嘗試了很多東西,但我認爲這個模式會起作用。在這裏控制數據庫創建的人有他的心在MyISAM,所以我不想讓他改變它,如果有什麼我可以做的解決它。可悲的是,我有創建數據庫的腳本,但是當我從已經存在的結構中生成模式時,它將遺漏關係,並且由於我對symfony不熟悉,因此我希望儘可能使所有內容自動化。

回答

2

我認爲問題在於您使用兩次相同的關係名稱。 我發現至少有三個:「UserState」,「BuyBackModel」,「BuyBackQuality」,在您的schema.yml中使用兩次。

嘗試確保所有關係都是唯一的,然後再次嘗試生成模型。

編輯

另一件事你應該嘗試,是增加類名到你的關係。

<...> 
Relations: 
    class: foo 
<...> 
+0

我繼續做了一個InnoDB,並根據它創建了一個模式。你應該使用類名作爲關係名。像這樣: 'States: ... 關係: 國家 地方:COUNTRY_ID 國外:ID 類型:一個 用戶: 地方:ID 國外:STATE_ID 類型:many' – KacieHouser 2010-08-18 18:17:52

+0

高興你想通弄明白了。 – jgallant 2010-08-19 10:58:27

0

我遇到了這個問題。這些想法都沒有奏效,因爲我認爲這是另一個問題。

./symfony學說:內置模式

不斷把舊的關係不再存在,到我的架構。所以無論是Symfony有一些模糊的地方,它緩存了舊的關係,或者MySQL正在報告不再存在的關係。

我認爲Symfony正在從其他來源,如窗體或過濾器拉關係。我將嘗試清除表單和過濾器的基本目錄。

嗯。找到了。在我的GUI中,外鍵在MySQL中沒有被刪除,在WorkBench中。你也必須刪除索引。

最佳解決方案。備份您的數據庫結構和內容。如果你的MySQL的GUI工具有問題,重新創建數據庫。