2012-02-02 73 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(); 
     } 
    } 


    /* ... */ 

}