I'm trying to change my PHP statement to Yii2. Here's the original code:
$sql = "select id from users where member_type='d'";
$max = @mysql_num_rows($r=mysql_query($sql));
for($i=0;$i<$max;$i++){
$demo2=mysql_fetch_assoc($r);
some_functions($demo2['id'], 'something');
}
I'm new to Yii2 framework and trying to convert it to Yii2 but have no idea how. I'm doing this function under a modal file.
Here's what I can do at best:
$max= Yii::$app->dbFxprimus->createCommand("select count(id) from ". $this->tableName() ." where member_type='d'")->queryAll();
for($i2=0;$i2<$max;$i2++){
$demo=mysql_fetch_assoc($max); //this is definitely wrong, help me to fix this, I don't know what is the Yii2 function for this.
some_function($demo['id'], 'something');
}
Can anyone help me to fix this?