yii make a join with CDbCriteria -


I want to get a model with its related, for example, I have a table game and another condition in betting There is a column with game_id

For now, I only recover the game model, not the related condition, despite being successful I try to connect one left. Here's what I have done

  $ criteria = new CDBCRITIA; $ Criteria- & gt; Select = '*'; $ Criteria- & gt; Alias ​​= 'game'; $ Criteria- & gt; Join = 'Game at bet on INNER JOIN. Id = bet.game_id'; //$criteria->condition='bet.user_id='.$_userId. 'Or user_id' is empty '; $ Criteria- & gt; Order = 'date_game ASC'; Return $ this- & gt; Model () - & gt; Search (all criteria);  

Thanks for your help

Model Returns are Properties On model. If you want that you with

in your model

  Expand Phrase Relationships () {Return Array ('Benmoddle' => Array (auto :: HAS_MANY, 'Ben', 'Game_ID' => ID;); }  

In your controller

  return $ this-> model () - & gt; From ('Benodel') - & gt; FindAll (); // You can get both table columns  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -