Some SQL improvements
This commit is contained in:
parent
a638417ab5
commit
8c35304013
1 changed files with 9 additions and 8 deletions
|
@ -881,17 +881,20 @@ function contact_posts($a, $contact_id) {
|
||||||
profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
|
profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT COUNT(*) AS `total` FROM `item`
|
if(get_config('system', 'old_pager')) {
|
||||||
WHERE `item`.`uid` = %d AND `contact-id` = %d AND `item`.`id` = `item`.`parent`",
|
$r = q("SELECT COUNT(*) AS `total` FROM `item`
|
||||||
intval(local_user()), intval($contact_id));
|
WHERE `item`.`uid` = %d AND (`author-link` = '%s')",
|
||||||
|
intval(local_user()), dbesc($contact["url"]));
|
||||||
|
|
||||||
$a->set_pager_total($r[0]['total']);
|
$a->set_pager_total($r[0]['total']);
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
||||||
`author-name` AS `name`, `owner-avatar` AS `photo`,
|
`author-name` AS `name`, `owner-avatar` AS `photo`,
|
||||||
`owner-link` AS `url`, `owner-avatar` AS `thumb`
|
`owner-link` AS `url`, `owner-avatar` AS `thumb`
|
||||||
FROM `item` WHERE `item`.`uid` = %d AND `contact-id` = %d
|
FROM `item` FORCE INDEX (uid_contactid_created)
|
||||||
AND ((`item`.`id` = `item`.`parent`) OR (`author-link` = '%s'))
|
WHERE `item`.`uid` = %d AND `contact-id` = %d
|
||||||
|
AND (`author-link` = '%s')
|
||||||
ORDER BY `item`.`created` DESC LIMIT %d, %d",
|
ORDER BY `item`.`created` DESC LIMIT %d, %d",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
intval($contact_id),
|
intval($contact_id),
|
||||||
|
@ -900,8 +903,6 @@ function contact_posts($a, $contact_id) {
|
||||||
intval($a->pager['itemspage'])
|
intval($a->pager['itemspage'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$tab_str = contact_tabs($a, $contact_id, 1);
|
$tab_str = contact_tabs($a, $contact_id, 1);
|
||||||
|
|
||||||
$header = $contact["name"];
|
$header = $contact["name"];
|
||||||
|
|
Loading…
Reference in a new issue