I am stuck trying to figure out why the following code snippet does not work as I would expect.
$sql = Yii::app()->db->createCommand()
->select('games.datetime, games.score_home_team, games.score_away_team, games.unit_home_team, games.unit_away_team, games.home_team_id, games.away_team_id')
->from('reindeer_games games')
->where((array('in','games.unit_home_team', ':unitIdArray') or array('in','games.unit_away_team', ':unitIdArray')) and 'games.season_id=:seasonId'), array(':unitIdArray'=>$levels, ':seasonId'=>$season_id))
->group('games.home_team_id, games.away_team_id')
->queryAll();
The where clause always evaluates to 1 but the season_id variable is not being enforced properly. I have checked and the season_id’s in the database are not all the same but I am receiving all of the records from every season_id value.
Am I using the proper format for mixing the IN comparisons with another WHERE clause? The only documentation I saw for using the IN clauses shows what I am doing, I have not seen any examples of mixing them with other bound variables.