2012-05-30 35 views
1

最近我將一列數據庫表更改爲另一個。執行遷移後的學說時,我做的事:如果我Symfony從路由中獲取對象不起作用

"SQLSTATE [42S22]: Column not found: 1054 Unknown column 'p.price_discount' in 'field list'"

ProductTable::getInstance()->find(1); 

一切正常

$this->getRoute()->getObject() 

我返回了一個錯誤!

我清空緩存完成1000次並構建 - 儘可能多。

我的schema.yml:

Product: 
    tableName: products 
    actAs: 
    Timestampable: 
     created: 
     name: created_at 
     type: timestamp 
     form: d-m-Y H:i:s 
    I18n: 
     fields: [title, subtitle, description, datasheet, returns_shippings, inspiration, use_care] 
     actAs: 
     Sluggable: { fields: [title], uniqueBy: [lang, title] } 
    columns: 
    id: 
     type: integer(4) 
     primary: true 
     notnull: true 
     autoincrement: true 
    ref: 
     type: string(45) 
     unique: true 
     notnull: true 
    active: 
     type: boolean 
     notnull: true 
     default: 0 
    new: 
     type: boolean 
     notnull: true 
     default: 0 
    title: 
     type: string(45) 
    subtitle: 
     type: string(45) 
    inspiration: clob 
    use_care: clob 
    brand: 
     type: string(45) 
    description: 
     type: clob(65535) 
    datasheet: 
     type: clob(65535) 
    returns_shippings: 
     type: clob(65535) 
    price: 
     type: float 
     notnull: true 
     default: 0 
    votes: 
     type: integer 
     notnull: true 
     default: 0 
    weight: 
     type: float 
     notnull: true 
     default: 0 
    iva_id: 
     type: integer(4) 
     notnull: true 
    relations: 
    Iva: 
     class: Iva 
     local: iva_id 
     foreign: id 
     foreignAlias: Products 
    Styles: 
     foreignAlias: Products 
     class: Style 
     refClass: StyleProduct 
     onDelete: CASCADE 
    Categories: 
     foreignAlias: Products 
     class: Category 
     refClass: CategoryProduct 
     onDelete: CASCADE 
    RelatedProducts: 
     foreignAlias: Products 
     class: Product 
     refClass: RelatedProduct 
     local: product_id 
     foreign: product_id1 
     onDelete: CASCADE 

會發生什麼?

+0

你重建了你的模型嗎? './symfony doctrine:build --model' – j0k

+0

我已經完成並構建 - 所有:-( – Mauro

+0

)您可以用'Product'表向我們展示您的schema.yml的一部分 – j0k

回答

1

您最近的評論是正確的。

Doctrine query cache使用apc作爲後端來存儲映射DQL request => SQL請求,這是很難計算的,並且幾乎不會改變:當您更改模型時它會更改。

例如,轉換如果添加一列到SQL時下面的查詢給出不同的結果:SELECT * FROM User u

這是因爲SQL請求列出了所有領域,所以什麼成爲

SELECT name, email FROM user 

應該成爲

SELECT name FROM user 

刪除電子郵件列後,但沒有因爲查詢緩存。