Events: Query improvement
This commit is contained in:
parent
4554526515
commit
c6e605992b
1 changed files with 50 additions and 48 deletions
10
mod/events.php
Executable file → Normal file
10
mod/events.php
Executable file → Normal file
|
@ -266,17 +266,19 @@ function events_content(&$a) {
|
||||||
|
|
||||||
if (x($_GET,'id')){
|
if (x($_GET,'id')){
|
||||||
$r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
|
$r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
|
||||||
`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id`
|
`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
|
||||||
|
LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
|
||||||
WHERE `event`.`uid` = %d AND `event`.`id` = %d",
|
WHERE `event`.`uid` = %d AND `event`.`id` = %d",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
intval($_GET['id'])
|
intval($_GET['id'])
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
|
$r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
|
||||||
`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id`
|
`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
|
||||||
|
LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
|
||||||
WHERE `event`.`uid` = %d and event.ignore = %d
|
WHERE `event`.`uid` = %d and event.ignore = %d
|
||||||
AND (( `adjust` = 0 AND ( `finish` >= '%s' OR ( nofinish AND start >= '%s' ) ) AND `start` <= '%s' )
|
AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')
|
||||||
OR ( `adjust` = 1 AND ( `finish` >= '%s' OR ( nofinish AND start >= '%s' ) ) AND `start` <= '%s' )) ",
|
OR (`adjust` = 1 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')) ",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
intval($ignored),
|
intval($ignored),
|
||||||
dbesc($start),
|
dbesc($start),
|
||||||
|
|
Loading…
Reference in a new issue