Im new to yii. my problem is, I have an array $hometeamid
which contains all the id that i need to display details. How can i get the data. plz somebody help me
I have tried $mod = Yii::app()->db->createCommand('SELECT * FROM event WHERE id = 1432201 or id = 1432208')->queryAll();
$no=1432201;
$mod = Event::model()->findByAttributes(array('id' => $no));<br>
but does not working. Blank fields are showing.
Best to do addInCriteria wiith CDbCriteria or simple createCommand like, but before do that please check your query on phpmyadmin/navicate/mysql workbench etc. manually (is it returning result or not?)
$homeTeamIds=['1','2','3','4'];
$criteria = new CDbCriteria;
$criteria->addInCondition('id',$homeTeamIds,'OR'); //matching any of your homeTeadIds
$result = Event::model()->findAll($criteria);
OR
$ids = implode(', ', $homeTeamIds);
$sql = "SELECT * FROM event WHERE id IN ($ids)" // like where id IN(1,2,3,4)
$result = Yii::app()->db->createCommand($sql)->queryAll();