2011-09-01 4 views
5

mi się ten komunikat o błędzie, gdy buduję model:ATTR_AUTO_ACCESSOR_OVERRIDE

When using the attribute ATTR_AUTO_ACCESSOR_OVERRIDE you cannot use the field name "attribute" ... 

Problemem jest to, że muszę używać tej nazwy pola, ponieważ jest w tabeli, która jest tworzony i wykorzystywany przez VirtueMart. Alias ​​też nie działa.

product_attribute: { name: product_attribute as attribute, type: clob(16777777) } 

Co mogę zrobić? Czy mogę wyłączyć ATTR_AUTO_ACCESSOR_OVERRIDE lub mam z tym problemy? Jeśli mogę, jak mogę to zrobić?

Czy może być problem z wyłączaniem ATTR_AUTO_ACCESSOR_OVERRIDE? A jeśli istnieje jeden (lub więcej), co to będzie?

Jestem wdzięczny za wszelkie porady!


Dodatkowe informacje:

Definicja w BaseJosVmProduct: @property clob $product_attribute

schema.yml:

JosVmProduct: 
    columns: 
    product_id:      { type: int, notnull: true, unique: true, primary: true, autoincrement: true } 
    vendor_id:      { type: int, notnull: true, default: 0 } 
    product_parent_id:    { type: int, notnull: true, default: 0 } 
    product_sku:     { type: string(64), , notnull: true, default: '' } 
    product_s_desc:     { type: string(255), default: null } 
    product_desc:     { type: clob(16777777) } 
    product_thumb_image:   { type: string(255), default: null } 
    product_full_image:    { type: string(255), default: null } 
    product_publish:    { type: string(1), default: null } 
    product_weight:     { type: decimal(10), scale: 4, default: null } 
    product_weight_uom:    { type: string(32), default: 'pounds.' } 
    product_length:     { type: decimal(10), scale: 4, default: null } 
    product_width:     { type: decimal(10), scale: 4, default: null } 
    product_height:     { type: decimal(10), scale: 4, default: null } 
    product_lwh_uom:    { type: string(32), default: 'inches' } 
    product_url:     { type: string(255), default: null } 
    product_in_stock:    { type: int, default: null } 
    product_available_date:   { type: int, default: null } 
    product_availability:   { type: string(56), notnull: true, default: '' } 
    product_special:    { type: string(1), default: null } 
    product_discount_id:   { type: int, default: null } 
    ship_code_id:     { type: int, default: null } 
    cdate:       { type: int, default: null } 
    mdate:       { type: int, default: null } 
    product_name:     { type: string(64), default: null } 
    product_sales:     { type: int, notnull: true, default 0 } 
    product_attribute:    { name: product_attribute as attribute, type: clob(16777777) } 
    custom_attribute:    { type: clob(16777777), notnull: true } 
    product_tax_id:     { type: int(2), notnull: true, default: '0' } 
    product_unit:     { type: string(32), default: null } 
    product_packaging:    { type: int, default: null } 
    webinar_duration:    { type: string(50), default: null } 
+0

Jaką wersję doktryny używasz, 1.2 lub 2.0? Pomocna może być także definicja jednostki. – J0HN

+0

Używam doktryny 1.2. – Andreas

Odpowiedz

4

Znalazłem lepsze rozwiązanie, umieścić to w klasie ProjectConfiguration:

public function configureDoctrine() 
     { 
     $isCli = (php_sapi_name() == "cli"); 
     if(true == $isCli) 
      { 
      Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, false); 
      } 
     } 

pracuje automatycznie wykrywanie i przełączanie kontekstu CLI właściwego atr off.

+0

To jest naprawdę miłe. Twoje zdrowie! – Andreas

+0

Pisałem o tym na moim blogu: http://blog.kowalczyk.cc/2011/09/16/symfony-blad-when-using-the-attribute-attr_auto_accessor_override-you- cannon-use-the-field-name /. Jest w języku polskim, ale mam nadzieję, że uda Ci się go przeczytać za pomocą Tłumacza Google. :) –

1

końcu znalazłem rozwiązanie tego problemu:

  • przełączyć ATTR_AUTO_ACCESSOR_OVERRIDE tymczasowo wyłączyć w 'mySymfonyFolder/lib/vendor/symfony/lib/plugins // sfDoctrinePlugin/config/sfDoctrineConfiguration.class.php'
  • tworzyć klasach
  • włącz go ponownie

Jeśli chcesz ustawić pole w kodzie, trzeba zrobić:

  • przełącznik ATTR_AUTO_ACCESSOR_OVERRIDE mecz -> setAttribute (Doctrine :: ATTR_AUTO_ACCESSOR_OVERRIDE, false);
  • z ustawieniem
  • ponownie włączyć za pomocą -> setAttribute (Doctrine :: ATTR_AUTO_ACCESSOR_OVERRIDE, true);