Answer the question
In order to leave comments, you need to log in
How to make a selection correctly in yii2?
I want to select records from a DB in a column where only integer values are stored.
But I need to select only unique records i.e. if the number is encountered repeatedly, then we do not pull out the data.
I know how to implement it, but I do several cycles. Too crooked I'm afraid. How can this be done?
//$array массив данных колонки с int значениями.
//$stop пустой массив.
if($stop===null){
echo $array['myint];
$stop[] = $array['myint];
}else{
for($i=0;$i<count($stop);$i++){
if($stop[i]!=$array['myint]){
echo $array['myint];
$stop[] = $array['myint];
}
}
}
//Плюс оборачиваю в еще один цикл, чтобы прогнать через все записи.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question