MySQL ANY_VALUE with fallback to MIN

https://github.com/friendica/friendica/issues/3322
This commit is contained in:
Alexandre Alapetite
2017-04-15 00:42:44 +02:00
parent 38e7a0f793
commit 1058b28cea
7 changed files with 42 additions and 22 deletions

View File

@@ -516,8 +516,9 @@ function notifier_run(&$argv, &$argc){
$r0 = Diaspora::relay_list();
}
$r1 = q("SELECT DISTINCT(`batch`), `id`, `name`,`network` FROM `contact` WHERE `network` = '%s'
AND `uid` = %d AND `rel` != %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` GROUP BY `batch`, `id` ORDER BY rand()",
$r1 = q("SELECT `batch`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`name`) AS `name`, ANY_VALUE(`network`) AS `network`
FROM `contact` WHERE `network` = '%s'
AND `uid` = %d AND `rel` != %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` GROUP BY `batch` ORDER BY rand()",
dbesc(NETWORK_DIASPORA),
intval($owner['uid']),
intval(CONTACT_IS_SHARING)