From 170b674a0953ce95e06f7a8442eb0f1097e7ee72 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 16 Mar 2003 07:02:20 +0000 Subject: - All LIMIT queries must go through the pager or through db_query_range(). The syntax for db_query_range() was enhanced so it matches db_query(). So you may pass extra arguments of the SQL statement which are checked via check_query() and then substituted into the SQL statement. After these optional arguments, you always pass $from and $count parameters which define your range. Most often, the $from is 0 and the count is the max number of records you want returned. Patch by Moshe. - The pager_query() function for PEAR was enhanced so that it adds proper GROUP BY statement counting the number of records to be paged. Patch by James Arthur. - MSSQL database scheme by Moshe. --- modules/blog.module | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules/blog.module') diff --git a/modules/blog.module b/modules/blog.module index 8646ea3f3..f8cd33d1f 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -86,7 +86,7 @@ function blog_feed_user($uid = 0) { $account = $user; } - $result = db_query("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = '%d' AND n.status = 1 ORDER BY n.nid DESC LIMIT 15", $uid); + $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = '%d' AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15); $channel["title"] = $account->name. "'s blog"; $channel["link"] = url("blog/view/$uid"); $channel["description"] = $term->description; @@ -94,7 +94,7 @@ function blog_feed_user($uid = 0) { } function blog_feed_last() { - $result = db_query("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC LIMIT 15"); + $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15); $channel["title"] = variable_get("site_name", "drupal") ." blogs"; $channel["link"] = url("blog/view"); $channel["description"] = $term->description; @@ -242,7 +242,7 @@ function blog_block($op = "list", $delta = 0) { } else { if (user_access("access content")) { - $block["content"] = node_title_list(db_query("SELECT u.uid, u.name, n.created, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC LIMIT 10")); + $block["content"] = node_title_list(db_query_range("SELECT u.uid, u.name, n.created, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10)); $block["content"] .= "
". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."
"; $block["subject"] = t("User blogs"); } -- cgit v1.2.3