Ben özel fonksiyonların saçma kombinasyonları başvurmadan bu sorun için herhangi aklı başında bir çözüm ile gelip olamaz. Belki bu biraz taze düşünce sağlayabilir.
Ben takip (basitleştirilmiş) dizi var
Array
(
[0] => Array
(
[vid_id] => 420037
[vid_rating] => 2.93827
[vid_quality] => 2
[vid_special] => 1
[vid_weight] => 0
[vid_position] => 0
[vid_position_end] => 0
)
[1] => Array
(
[vid_id] => 420040
[vid_rating] => 3
[vid_quality] => 1
[vid_special] => 1
[vid_weight] => 0
[vid_position] => 0
[vid_position_end] => 0
)
[2] => Array
(
[vid_id] => 426455
[vid_rating] => 3.25581
[vid_quality] => 2
[vid_special] => 0
[vid_weight] => 5
[vid_position] => 1
[vid_position_end] => 2
)
[3] => Array
(
[vid_id] => 429804
[vid_rating] => 3
[vid_quality] => 2
[vid_special] => 0
[vid_weight] => 0
[vid_position] => 0
[vid_position_end] => 0
)
[4] => Array
(
[vid_id] => 420848
[vid_rating] => 2.94444
[vid_quality] => 2
[vid_special] => 0
[vid_weight] => 3
[vid_position] => 1
[vid_position_end] => 2
)
[5] => Array
(
[vid_id] => 420859
[vid_rating] => 2.73077
[vid_quality] => 2
[vid_special] => 0
[vid_weight] => 4
[vid_position] => 1
[vid_position_end] => 2
)
[6] => Array
(
[vid_id] => 420524
[vid_rating] => 2.41379
[vid_quality] => 2
[vid_special] => 0
[vid_weight] => 5
[vid_position] => 2
[vid_position_end] => 2
)
[7] => Array
(
[vid_id] => 419810
[vid_rating] => 3.13393
[vid_quality] => 1
[vid_special] => 0
[vid_weight] => 0
[vid_position] => 0
[vid_position_end] => 0
)
[8] => Array
(
[vid_id] => 419851
[vid_rating] => 2.97802
[vid_quality] => 1
[vid_special] => 0
[vid_weight] => 5
[vid_position] => 1
[vid_position_end] => 2
)
[9] => Array
(
[vid_id] => 419843
[vid_rating] => 2.95349
[vid_quality] => 1
[vid_special] => 0
[vid_weight] => 3
[vid_position] => 1
[vid_position_end] => 2
)
[10] => Array
(
[vid_id] => 419838
[vid_rating] => 2.73529
[vid_quality] => 1
[vid_special] => 0
[vid_weight] => 4
[vid_position] => 1
[vid_position_end] => 2
)
)
Bu dizi, bu mysql sorgunun bir sonucudur
SELECT
vid_id,
vid_rating,
vid_quality,
vid_special,
vid_weight,
vid_position,
vid_position_end
FROM versions
WHERE vid_movid = 'xxxxx' AND vid_status = 1
ORDER BY vid_special DESC, vid_quality DESC, vid_rating DESC
Bu web sitesi linkleri (fiili bağlantı sütun basitlik için kaldırılır) bir listesini verir, bu ihtiyacı çok özel bir sıraya koymak gerekir. Ben bitti gereken ne yapıyorsun birkaç unioned sorgu ile mümkündür .... ama gerçekten maliyeti çok yüksek olacağından, bu başvurmak istemiyorum, bu yüzden dizileri daha kolay olurdu manipüle düşündüm.
Ben seçici bu diziden birkaç bağlantıları ayıklamak, ve belirli bir düzen içinde, dizinin üstüne onları sopa gerekir.
Links marked with vid_position, and vid_position_end denote a range that this group will occupy. Meaning that if there are several links marked with those positions, only 2 will be pushed to the top, if the range is 1-2. if its 1-3, then top 3 positions will be occupied.
The weight denotes the ORDER in which links must be sorted. So if there are 5 different links, with 5 different weights in a position range of 1-2, only the top 2 weights will be pushed to the top. The remaining 3 will remain where they are.
there are different groups of links. In this case, there is a group 1-2, and 3-3. First group occupies the first 2 positions, and in my example has 3 weight classes. the other group occupires the 3rd position, and only has 1 weight class.
The ordering should be independent. If there are no links in the 1-2 group, but there are links in 3-3, that means 3-3 grouped links will appear in the first position.