次のテーブルがあります。
user (id, cv_personal_data_id),
cv_personal_data (id, firstname, surname, gender, address, ...),
cv_laboral_exp (id, user_id, position, seniority,... ),
cv_study (id, user_id, name, institution, average, ...),
cv_language (id, user_id, language_name, writing_level, ...)
私の User モデルでは、次の関係を定義しました。
public function relations()
{
return array(
'cvLaboralExps' => array(self::HAS_MANY, 'CvLaboralExp', 'user_id'),
'cvLanguages' => array(self::HAS_MANY, 'CvLanguage', 'user_id'),
'cvStudies' => array(self::HAS_MANY, 'CvStudy', 'user_id'),
'cvPersonalData' => array(self::BELONGS_TO, 'CvPersonalData', 'cv_personal_data_id'),
}
問題は次のとおりです。会社としてログインし、すべてのユーザーを一覧表示する CGridView を表示し、関連するテーブルの任意のフィールド (「位置」(cv_laboral_exp から)、「言語名」(からcv_languages) などです。HAS_MANY リレーションからのフィールドを検索する解決策が見つからないようです。ユーザーの労働経験の位置を検索しようとして、User クラスの search() メソッドに 'with' ステートメントを $criteria に追加しようとしましたが、成功しませんでした。
$criteria->compare('cvLaboralExps.position',$this->cvLaboralExps,true);
$criteria->with = array('cvLaboralExps'=>array('select'=>'cvLaboralExps.position','together'=>true));
ご覧のとおり、ユーザーの CV を形成する多くの関係があります。データベース/モデル構造の変更を意味する場合でも、誰かがこれを解決するのを手伝ってくれたらとても感謝しています。