Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Relations, Scopes, Subqueries And Finder Params

$
0
0
Is possible to do that?

public function scopes()
{
  return array(
   'completed'=>array(
	'join'=>'INNER JOIN jobs_role j1 ON j1.job_id = '.$this->tableAlias.'.id',
	'group' => $this->tableAlias.'.id',
    ),
   'drafted'=>array(
      'condition'=>$this->tableAlias.'.id NOT IN (SELECT jobjoin.id from jobs_job jobjoin INNER JOIN jobs_role rolejoin ON jobjoin.author_id = :ypl0 AND  rolejoin.job_id = jobjoin.id)',
      'group' => $this->tableAlias.'.id',
       ),
     );
}


I mean, could I use the ":ypl0" finder param directly in my subquery? The code works like a charm but... I think is not very orthodox. What others ways exists in yii to use this value in the subquery.

It is really strange I know. But this scope is only used to defined a relation in another model, so in need this :ypl0 (the id used in Where clause). Can I do in other way?

Thank you

Viewing all articles
Browse latest Browse all 18717

Latest Images

Trending Articles

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>