M
M
Maxim Fedorov2017-08-06 19:59:43
Yii
Maxim Fedorov, 2017-08-06 19:59:43

How to display data twice from a database table without duplicating code?

How in Yii 2 to immediately display a double set of data from one table without duplicating the code, one full, the other partial?
Example https://yadi.sk/i/Luz7-WfZ3LkrPY
On the left there are only 10 records (filtered by some attribute), on the right on the map all records from the table

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vyachin, 2017-08-07
@vyachin

give an example of a working code with duplication, and we will tell you what to fix.
ps. My option is to leave it as it is and continue to work on the rest of the functionality and start earning $ as soon as possible

M
Maxim Timofeev, 2017-08-07
@webinar

How to immediately display a double set of data from one table in Yii 2 without duplicating the code

What's the problem?
$data = Mymodel::find()->all(); //все записи
$data10 = array_slice($data, 10); //первые 10 из всех записей

If you have already received everything, then you already have 10. More to think about:
$data = Mymodel::find()->all(); //все записи

//выводим первые 10
for($i=0;$<10;$i++){
echo  $data[$i]->title;
}

//выводим все
foreach($data as $one){
echo  $one->title;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question