私はYii拡張機能に従いました:通常、多言語動作の指示、そしてこれが私のモデル動作設定です:
public function behaviors()
{
return array(
'ml' => array(
'class' => 'application.models.behaviors.MultilingualBehavior',
'langClassName' => 'CandidateLang',
'langTableName' => 'candidatelang',
'langForeignKey' => 'candidate_id',
'langField' => 'lang_id',
'localizedAttributes' => array('name', 'birth_place', 'home_city', 'intro'), //attributes of the model to be translated
'localizedPrefix' => 'l_',
'languages' => Yii::app()->params['languages'], // array of your translated languages. Example : array('fr' => 'Français', 'en' => 'English')
'defaultLanguage' => 'en', //your main language. Example : 'fr'
'createScenario' => 'insert',
'localizedRelation' => 'i18nCandidate',
'multilangRelation' => 'multilangCandidate',
'forceOverwrite' => false,
'forceDelete' => true,
'dynamicLangClass' => true, //Set to true if you don't want to create a 'PostLang.php' in your models folder
),
);
}
CDbExceptionが発生します:アクティブレコードクラス「CandidateLang」のテーブル「{{candidatelang}}」がデータベースに見つかりません。
エラーがトリガーされた場所は次のとおりです。
private $_model;
2253
2254 /**
2255 * Constructor.
2256 * @param CActiveRecord $model the model instance
2257 */
2258 public function __construct($model)
2259 {
2260 $this->_model=$model;
2261
2262 $tableName=$model->tableName();
2263 if(($table=$model->getDbConnection()->getSchema()- >getTable($tableName))===null)
2264 throw new CDbException(Yii::t('yii','The table "{table}" for active record class "{class}" cannot be found in the database.',
2265 array('{class}'=>get_class($model),'{table}'=>$tableName)));
2266 if($table->primaryKey===null)
2267 {
2268 $table->primaryKey=$model->primaryKey();
2269 if(is_string($table->primaryKey) && isset($table->columns[$table->primaryKey]))
2270 $table->columns[$table->primaryKey]->isPrimaryKey=true;
2271 else if(is_array($table->primaryKey))
2272 {
2273 foreach($table->primaryKey as $name)
2274 {
2275 if(isset($table->columns[$name]))
2276 $table->columns[$name]->isPrimaryKey=true;
テーブルがそこにあることを確認し、ケーシングとスペルを再確認しました。運が悪かったので、スキーマとは異なるテーブル名を付けてみました。だから、この呼び出しがエラーを引き起こしていると私は推測します:
$model->getDbConnection()
、しかし私はそれを修正する理由または方法がわかりませんか?