2011-09-01 7 views
5

ottengo questo messaggio di errore quando sto costruendo il modello:ATTR_AUTO_ACCESSOR_OVERRIDE

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

Il problema è che devo usare tale nome del campo, perché è in una tabella che viene creato e utilizzato da VirtueMart. Alias ​​non funziona neanche.

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

Quindi, cosa posso fare? Posso disattivare lo ATTR_AUTO_ACCESSOR_OVERRIDE o ho problemi con questo. Nel caso io possa, come posso farlo?

Potrebbe esserci un problema con lo spegnimento dello ATTR_AUTO_ACCESSOR_OVERRIDE? E se ce n'è uno (o più), quale sarà?

Sono grato per qualsiasi consiglio!


Informazioni aggiuntive:

Definizione in 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

Quale versione della dottrina stai usando, 1.2 o 2.0? Inoltre, la definizione dell'entità potrebbe aiutare. – J0HN

+0

Sto usando doctrine 1.2. – Andreas

risposta

4

ho trovato una soluzione migliore, mettere questo in classe ProjectConfiguration:

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

Opere rilevando automaticamente contesto CLI e la commutazione corretta ATTR off.

+0

Questo è veramente pulito. Saluti! – Andreas

+0

Ho scritto di questo sul mio blog: http://blog.kowalczyk.cc/2011/09/16/symfony-blad-when-using-the-attribute-attr_auto_accessor_override-you-cannot-use-the-field-name /. È in polacco, ma spero che riuscirai a leggerlo con Google Translate. :) –

1

ho finalmente trovato una soluzione per questo:

  • passare ATTR_AUTO_ACCESSOR_OVERRIDE temporaneamente in 'mySymfonyFolder/lib/vendor/symfony/lib/plugins // sfDoctrinePlugin/config/sfDoctrineConfiguration.class.php'
  • creare le classi
  • riaccenderlo

Se vuole impostare il campo nel codice, si deve fare:

  • interruttore ATTR_AUTO_ACCESSOR_OVERRIDE via con -> setAttribute (Doctrine :: ATTR_AUTO_ACCESSOR_OVERRIDE, false);
  • fare l'impostazione
  • accenderlo di nuovo con -> setAttribute (Doctrine :: ATTR_AUTO_ACCESSOR_OVERRIDE, true);