1

最近、データベーステーブルの列を別の列に変更しました。私が行うときに移行の教義を実行した後:

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

エラーを返しました:

"SQLSTATE [42S22]:列が見つかりません:1054不明な列'p.price_discount' in'field list'"

もし私が:

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

すべてが正常に動作します!

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

何が起こるのですか?

4

1 に答える 1

1

あなたの最後のコメントは正しいです。

Doctrineクエリキャッシュは、マッピングDQLリクエスト=> SQLリクエストを格納するバックエンドとしてapcを使用しています。これは計算が難しく、ほとんど変更されません。モデルを変更すると変更されます。

たとえば、次のクエリでは、列を追加するとSQLに変換されたときに異なる結果が得られます。SELECT * FROM User u

これは、SQLリクエストにすべてのフィールドがリストされているためです。

SELECT name, email FROM user

になる必要があります

SELECT name FROM user

電子メール列を削除した後ですが、クエリキャッシュが原因ではありません。

于 2012-05-30T21:57:22.443 に答える