Search code examples
modeldoctrinesymfony1

yet another Unknown record property / related component


I have this Symfony Recepciones class which is related to a Obras_Sociales_Recepciones class as my BaseRecepciones class claims:

   /* @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'));
            }
        }

however... when I do this on an action

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

it says:

Unknown record property / related component "obras_sociales_recepciones" on "Recepciones"

any ideas?


Solution

  • I finally discovered what happened, i hope it helps someone save the two or three days it took me to figure this out.

    Doctrine 1.2 accepts only two types of notations for table names

    CamelCase Or underscored_notation. Internally it recognizes any of them and its able to transform the former to the latter and vice-versa .

    In my case if my table name was called "obras_sociales_recepciones" or "ObrasSocialesRecepciones" this error would've never ocurred.

    the thing is that in Doctrine 1.2 you should never use a mix of CamelCase AND underscore notation, this is in my example Obras_Sociales_Recepciones, this absolutely confuses the ORM and you might recieve this strange error and never find out why!