2014-02-09 9 views
0

내 테이블 Empresa에 새 필드를 추가 했으므로 모델을 변경해야합니다. 모델 폼 필터 내가 (수동) 수동으로 추가하기로 결정을 의미하는 전체 일을 재생 그래서 나는 다음과 같이 BaseSdrivingEmpresa.class.php에 속성을 추가하려고 해요없는 경우 :Symfony1.4 및 Doctrine의 기본 모델에 손으로 속성 추가

<?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, 
     )); 
    } 

} 

하지만이 오류가 발생합니다 :

500 | Internal Server Error | Doctrine_Record_UnknownPropertyException

나는 속성은 템플릿에 표시 할 얻으려고 할 때마다 :

$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() ?> 

내 오류가 무엇입니까?

답변

2

먼저이 의 수동 편집은이 클래스가 자동으로 생성되며 다음 모델 빌드로 덮어 쓰게되므로 바람직하지 않습니다. 수동으로 수행하려는 경우 BaseSdrivingEmpresa.class.php의 직계 하위 (SdrivingEmpresa.class.php)로 처리해야합니다. 두 번째로 더 나은 곳은 SdrivingEmpresaTable.class.php입니다. 이처럼 보이는, 그래서 나는 수정 getInstance 방법을 제안 :

public static function getInstance() 
{ 
    $this->setColumn('umbralvoz', 'integer', 11, array(
     'type' => 'integer', 
     'notnull' => false, 
     'default' => 60, 
     'length' => 11, 
    )); 
    return Doctrine_Core::getTable('SdrivingEmpresa'); 
} 

가 마지막으로,이 경우 가장 좋은 방법은 단지 명령, 당신의 schema.yml 파일을 수정하여 열을 추가 한 다음 사용하고 있다고 생각

./symfony doctrine:build-model 

언급 한 필터, 양식을 건드리지 않고 모델을 다시 작성합니다.