在构建模型时,我会收到以下错误消息:
When using the attribute ATTR_AUTO_ACCESSOR_OVERRIDE you cannot use the field name "attribute" ...问题是,我必须使用这个字段名,因为它位于一个由虚拟者创建和使用的表中。别名也不起作用。
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:
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 }发布于 2011-09-17 00:52:33
我找到了更好的解决方案,将其放在ProjectConfiguration类中:
public function configureDoctrine()
{
$isCli = (php_sapi_name() == "cli");
if(true == $isCli)
{
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, false);
}
}工作自动检测CLI上下文和切换适当的ATTR关闭。
发布于 2011-09-02 03:16:28
我终于找到了一个解决办法:
'mySymfonyFolder/lib/vendor/symfony/lib/plugins//sfDoctrinePlugin/config/sfDoctrineConfiguration.class.php'
ATTR_AUTO_ACCESSOR_OVERRIDE临时关闭类如果要在代码中设置字段,则必须执行以下操作:
用->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE,false关闭
ATTR_AUTO_ACCESSOR_OVERRIDE );https://stackoverflow.com/questions/7266293
复制相似问题