Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は会社の内部管理システムの開発にYiiを使用しています。モデルを作成しましたがJobs、このモデルQuotesはタイプHAS_MANYのモデルと関係があります。リレーション名はquotesです。次に、すべての行を選択する必要があります(モデルJobsはMySQLテーブルjobsをソースとして使用します)。各ジョブには正確に0の引用符が関連付けられています。これをスコープとしてモデルに追加しようと思いました。どうすればこれを達成できますか?
Jobs
Quotes
quotes
jobs
モデルに追加:
public function scopes() { return array( 'withoutQuotes'=>array( 'with'=>'quotes', 'condition'=>'quotes.id is null', ), ); }
その後、
$model->withoutQuotes()->search() //etc