I have added a new field to my table Empresa
so I need to change my model. For not regenerate the whole things meaning model-forms-filters I decide to add it by hand (manually) so I'm trying to add a the property to BaseSdrivingEmpresa.class.php
as follow:
<?php
/**
* BaseSdrivingEmpresa
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $umbralvoz
*
* @method integer getUmbralvoz() Returns the current record's "umbralvoz" value
* @method SdrivingEmpresa setUmbralvoz() Sets the current record's "umbralvoz" value
*
* @package isecurdriving
* @subpackage model
* @author Your name here
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class BaseSdrivingEmpresa extends sfDoctrineRecord {
public function setTableDefinition() {
$this->setTableName('sdriving_empresa');
$this->hasColumn('umbralvoz', 'integer', 11, array(
'type' => 'integer',
'notnull' => false,
'default' => 60,
'length' => 11,
));
}
}
But I get this error:
500 | Internal Server Error | Doctrine_Record_UnknownPropertyException
Any time I try to get the property to display it on a template:
$id_empresa = $this->getUser()->getGuardUser()->getSfGuardUserProfile()->getIdempresa();
$this->sdriving_configuracion = Doctrine_Core::getTable('SdrivingEmpresa')->createQuery('a')->where('a.idempresa = ?', $id_empresa)->execute();
<?php echo $sdriving_configuracion[0]->SdrivingEmpresa->getUmbralvoz() ?>
Where is my error?
First of all manual edit of your Base*.class.php
is not a good idea as this class is meant to be generated automatically and will be overwritten by next model build. If you want to do anything manually you should do it in direct child of BaseSdrivingEmpresa.class.php
which is SdrivingEmpresa.class.php
.
Second thing is that better place for such modification is SdrivingEmpresaTable.class.php
. I would suggest modifying getInstance
method so it looks like:
public static function getInstance()
{
$this->setColumn('umbralvoz', 'integer', 11, array(
'type' => 'integer',
'notnull' => false,
'default' => 60,
'length' => 11,
));
return Doctrine_Core::getTable('SdrivingEmpresa');
}
Finally, I think that in this case best solution is just simply modify your schema.yml
file, add your column and then use command
./symfony doctrine:build-model
which will rebuild your model without touching forms, filters which you mentioned.