Model 另一个未知的记录属性/相关组件

Model 另一个未知的记录属性/相关组件,model,doctrine,symfony1,Model,Doctrine,Symfony1,我有一个Symfony Recepciones类,它与我的BaseRecepciones类声明的Obras_Sociales_Recepciones类相关: /* @method Recepciones setRecepcionId() Sets the current record's "recepcion_id" value * @method Recepciones setCu

我有一个Symfony Recepciones类,它与我的BaseRecepciones类声明的Obras_Sociales_Recepciones类相关:

   /* @method Recepciones          setRecepcionId()                       Sets the current record's "recepcion_id" value
    * @method Recepciones          setCuentaLaboratorioId()               Sets the current record's "cuenta_laboratorio_id" value
    * @method Recepciones          setCuentasLaboratorios()               Sets the current record's "Cuentas_Laboratorios" value
    * @method Recepciones          setObrasSocialesRecepciones()          Sets the current record's "Obras_Sociales_Recepciones" collection
    */
        abstract class BaseRecepciones extends sfDoctrineRecord
        {
            public function setTableDefinition()
            {
                $this->setTableName('Recepciones');
                $this->hasColumn('recepcion_id', 'integer', 4, array(
                     'type' => 'integer',
                     'fixed' => 0,
                     'unsigned' => true,
                     'primary' => true,
                     'autoincrement' => true,
                     'length' => 4,
                         ));
                $this->hasColumn('cuenta_laboratorio_id', 'integer', 4, array(
                     'type' => 'integer',
                     'fixed' => 0,
                     'unsigned' => true,
                     'primary' => false,
                     'notnull' => true,
                     'autoincrement' => false,
                     'length' => 4,
                     ));
            }
        
            public function setUp()
            {
                parent::setUp();
                $this->hasOne('Cuentas_Laboratorios', array(
                     'local' => 'cuenta_laboratorio_id',
                     'foreign' => 'cuenta_laboratorio_id'));
        
                $this->hasMany('Obras_Sociales_Recepciones', array(
                     'local' => 'recepcion_id',
                     'foreign' => 'recepcion_id'));
            }
        }
然而。。。当我在一个动作中这样做的时候

$recepcionPrueba = new Recepciones();
$recepcionPrueba->setObrasSocialesRecepciones($myObject);
它说:

“收据”上的未知记录属性/相关组件“obras_sociales_recepciones”


有什么想法吗?

只是一个猜测,因为我是一个用户。。。将
parent::setUp()
移动到setUp方法的末尾会有帮助吗?我想知道家长是否对关系做了一些事情,并且无法确定您是否在呼叫家长后定义了这些关系。

只是一个猜测,因为我是一个用户。。。将
parent::setUp()
移动到setUp方法的末尾会有帮助吗?我想知道家长是否对关系做了一些事情,并且无法在调用家长后定义它们。

在选择型号名称时避免使用复数名称(在您的情况下,您应该使用
Recepcion
)。你能在BaseReceives之前发表评论吗?好的方法名称应该出现在这个注释中,我想这有点奇怪,比如
setobrassocialeservecioness()
和2's'

在选择模型名称时避免使用复数名称(在您的情况下,您应该使用
Recepcion
)。你能在BaseReceives之前发表评论吗?好的方法名称应该出现在这个注释中,我猜它有点奇怪,比如带有2’s’的
setobrassocialessrecepcioness()
,它是一对多,所以你不需要:

$recepcionPrueba->setObrasSocialesRecepciones($myObject);
是吗

$recepcionPrueba->addObrasSocialesRecepciones($myObject);

您可以一对一地调用“set”。

这是一对多,所以您不需要:

$recepcionPrueba->setObrasSocialesRecepciones($myObject);
是吗

$recepcionPrueba->addObrasSocialesRecepciones($myObject);

您可以一对一地调用“set”。

我终于发现了发生的事情,我希望它能帮助别人节省我花了两三天时间才弄明白的时间

原则1.2只接受两种类型的表名符号

或加下划线的符号。在内部,它认识到其中任何一个,并能够将前者转化为后者,反之亦然

在我的例子中,如果我的表名被称为“obras_sociales_recepciones”或“ObrasSocialesRecepciones”,那么这个错误永远不会发生


问题是,在原则1.2中,你应该永远不要混合使用CamelCase和下划线符号,这是我的例子Obras_Sociales_Recepciones,这绝对会混淆ORM,你可能会收到这个奇怪的错误,永远也找不到原因

我终于发现了发生的事情,我希望这能帮助别人省下我花了两三天时间才弄明白的事情

原则1.2只接受两种类型的表名符号

或加下划线的符号。在内部,它认识到其中任何一个,并能够将前者转化为后者,反之亦然

在我的例子中,如果我的表名被称为“obras_sociales_recepciones”或“ObrasSocialesRecepciones”,那么这个错误永远不会发生


问题是,在原则1.2中,你应该永远不要混合使用CamelCase和下划线符号,这是我的例子Obras_Sociales_Recepciones,这绝对会混淆ORM,你可能会收到这个奇怪的错误,永远也找不到原因

很抱歉,这不是解决方案,我只是添加了出现在函数签名之前的注释。这不是解决方案,我只是添加了出现在函数签名之前的注释。我想你真的应该切换到单数名称。看到这条线索了吗?还有这条:你还是应该改用单数名字。看到这个线程:这个线程:同样的问题是:表名是“amount\u cur”,但条令想要访问表“amount\u cur”,但不能(表名是动态形成的)。谢谢同样的问题是:表名是“amount\u cur”,但条令希望访问表“amount\u cur”,但无法访问(表名是动态形成的)。谢谢