2012-02-02 77 views
0

我正在使用Symfony 1.4应用程序,并使用ItrN InN。为了满足灵活性需求,我正在迁移我的数据库体系结构,这样我就有2个MySQL数据库:1个主数据库和1个从数据库。这就是为什么我决定使用sfDoctrineMasterSlavePlugin,这对于这种新配置来说非常完美。不幸的是,我现在正在使用I18N出现一些错误。下面是我的配置:sfDoctrineMasterSlavePlugin和I18N错误“未知的关系别名翻译”

databases.yml里

dev: 
    master: 
    class: sfDoctrineDatabase 
    param: 
     dsn:  mysql:host=localhost;dbname=my_db; 
     username: **** 
     password: **** 

    slave: 
    class: sfDoctrineDatabase 
    param: 
     dsn:  mysql:host=localhost;dbname=my_db; 
     username: **** 
     password: **** 

的schema.yml

Data: 
    actAs: 
    I18n: 
     fields: [name] 
    columns: 
    name: { type: string(255) } 

在我的模板

<?php echo $data->getName(); ?> 

我得到这个错误

Unknown relation alias Translation 

我找不到为什么这种关系将无法正常工作某种原因!...我发现有些人得到同样的错误,但没有找到任何解决办法...

有没有人有一个想法?

+0

你得到这个错误与所有的I18n关系?或者只是用这个? – dlondero 2012-02-02 15:56:56

+0

对不起,迟到的回应,但我没有得到您的评论通知......其实我有这个错误与我所有的国际关系。而我仍然没有找到任何解决方案使其正常工作!... – TiuSh 2012-03-19 11:02:15

回答

1

我终于找到了一个解决方案感谢乔Siponen从http://www.doctrine-project.org/jira/browse/DC-363(见职位说明)

在LIB /供应商/ symfony的/ lib目录/插件/ sfDoctrinePlugin/lib中/供应商/学说/教义/录音/发电机.PHP:

abstract class Doctrine_Record_Generator extends Doctrine_Record_Abstract 
{ 
    protected static $lastConnectionHash = null; 

    /* ... */ 

    public function initialize(Doctrine_Table $table) 
    { 
     if ($this->_initialized) { 
      return false; 
     } 

     $this->_initialized = true; 

     $this->initOptions(); 

     $table->addGenerator($this, get_class($this)); 

     $this->_options['table'] = $table; 

     $ownerClassName = $this->_options['table']->getComponentName(); 
     $className = $this->_options['className']; 
     $this->_options['className'] = str_replace('%CLASS%', $ownerClassName, $className); 

     if (isset($this->_options['tableName'])) { 
      $ownerTableName = $this->_options['table']->getTableName(); 
      $tableName = $this->_options['tableName']; 
      $this->_options['tableName'] = str_replace('%TABLE%', $ownerTableName, $tableName); 
     } 

     // check that class doesn't exist (otherwise we cannot create it) 
     if ($this->_options['generateFiles'] === false && class_exists($this->_options['className'])) { 
      $this->_table = Doctrine_Core::getTable($this->_options['className']); 
      return false; 
     } 

     $currentConnectionHash = spl_object_hash($table->getConnection()->getDbh()); 

     if ($currentConnectionHash != self::$lastConnectionHash) 
     { 
      self::$lastConnectionHash = $currentConnectionHash; 

      $this->buildTable(); 

      $fk = $this->buildForeignKeys($this->_options['table']); 

      $this->_table->setColumns($fk); 

      $this->buildRelation(); 

      $this->setTableDefinition(); 
      $this->setUp(); 

      $this->generateClassFromTable($this->_table); 

      $this->buildChildDefinitions(); 

      $this->_table->initIdentifier(); 
     } 
    } 


    /* ... */ 

}