首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ATTR_AUTO_ACCESSOR_OVERRIDE

ATTR_AUTO_ACCESSOR_OVERRIDE
EN

Stack Overflow用户
提问于 2011-09-01 05:01:47
回答 2查看 1.1K关注 0票数 4

在构建模型时,我会收到以下错误消息:

代码语言:javascript
复制
When using the attribute ATTR_AUTO_ACCESSOR_OVERRIDE you cannot use the field name "attribute" ...

问题是,我必须使用这个字段名,因为它位于一个由虚拟者创建和使用的表中。别名也不起作用。

代码语言:javascript
复制
product_attribute: { name: product_attribute as attribute,  type: clob(16777777) }

那我能做什么呢?我能关掉ATTR_AUTO_ACCESSOR_OVERRIDE吗?或者我有问题吗?万一我可以,我怎么能做到呢?

关掉ATTR_AUTO_ACCESSOR_OVERRIDE会有什么问题吗?如果有一个(或更多),它会是什么?

我很感谢你的建议!

其他信息:

BaseJosVmProduct中的定义:@property clob $product_attribute

schema.yml:

代码语言:javascript
复制
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 }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-09-17 00:52:33

我找到了更好的解决方案,将其放在ProjectConfiguration类中:

代码语言:javascript
复制
public function configureDoctrine()
        {
        $isCli = (php_sapi_name() == "cli");
        if(true == $isCli)
            {
            Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, false);
            }
        }

工作自动检测CLI上下文和切换适当的ATTR关闭。

票数 3
EN

Stack Overflow用户

发布于 2011-09-02 03:16:28

我终于找到了一个解决办法:

'mySymfonyFolder/lib/vendor/symfony/lib/plugins//sfDoctrinePlugin/config/sfDoctrineConfiguration.class.php'

  • create中的
  • ATTR_AUTO_ACCESSOR_OVERRIDE临时关闭类
  • 再次打开

如果要在代码中设置字段,则必须执行以下操作:

用->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE,false关闭

  • );
  • 使用->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE,true再次打开ATTR_AUTO_ACCESSOR_OVERRIDE );
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7266293

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档