[pLog-svn] r2355 - plog/branches/plog-1.0.2/class/dao
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sun Jul 24 09:49:52 GMT 2005
Author: oscar
Date: 2005-07-24 09:49:51 +0000 (Sun, 24 Jul 2005)
New Revision: 2355
Modified:
plog/branches/plog-1.0.2/class/dao/articlecategories.class.php
Log:
reverted articlecategories.class.php to rev 2315 so that it works... the sql query is not quite correct at the moment (it only returns categories that have at least one article assigned to them)
In any case, this has already been fixed in plog 1.1. I have denormalized the fields that count
the number of articles so that loading the list of categories from a blog is just a single SELECT
query without costly JOIN operations.
Modified: plog/branches/plog-1.0.2/class/dao/articlecategories.class.php
===================================================================
--- plog/branches/plog-1.0.2/class/dao/articlecategories.class.php 2005-07-24 08:18:55 UTC (rev 2354)
+++ plog/branches/plog-1.0.2/class/dao/articlecategories.class.php 2005-07-24 09:49:51 UTC (rev 2355)
@@ -167,9 +167,8 @@
c.last_modification AS last_modification, c.in_main_page AS in_main_page,
c.parent_id AS parent_id, c.description AS description, c.properties AS properties,
c.mangled_name AS mangled_name, IF(a.id IS NULL, 0, COUNT(*)) AS num_articles, a.date AS last_update
- FROM {$prefix}articles a
- LEFT JOIN {$prefix}articles_categories c ON c.id = l.category_id
- LEFT JOIN {$prefix}article_categories_link l ON a.id = l.article_id
+ FROM {$prefix}articles_categories c LEFT JOIN {$prefix}article_categories_link l
+ ON c.id=l.category_id LEFT JOIN {$prefix}articles a ON a.id = l.article_id
WHERE c.blog_id = '".Db::qstr($blogId)."'";
if( $onlyInMainPage )
@@ -195,7 +194,7 @@
}
elseif( $order == BLOG_CATEGORIES_MOST_RECENT_UPDATED_FIRST ) {
$query .= "ORDER BY last_update DESC, name ASC;";
- }
+ }
return $this->_getBlogCategoriesFromQuery( $query, $page, $itemsPerPage );
}
@@ -211,9 +210,8 @@
c.last_modification AS last_modification, c.in_main_page AS in_main_page,
c.parent_id AS parent_id, c.properties AS properties, c.description AS description,
c.mangled_name AS mangled_name, IF(a.id IS NULL, 0, COUNT(*)) AS num_articles, a.date AS last_update
- FROM {$prefix}articles a
- LEFT JOIN {$prefix}articles_categories c ON c.id = l.category_id
- LEFT JOIN {$prefix}article_categories_link l ON a.id = l.article_id
+ FROM {$prefix}articles_categories c LEFT JOIN {$prefix}article_categories_link l
+ ON c.id=l.category_id LEFT JOIN {$prefix}articles a ON a.id = l.article_id
WHERE c.blog_id = $blogId";
if( $onlyInMainPage )
@@ -480,10 +478,9 @@
$query = "SELECT a.id as article_id, c.id AS id, c.name AS name, c.url AS url, c.blog_id AS blog_id,
c.last_modification AS last_modification, c.in_main_page AS in_main_page,
c.parent_id AS parent_id, c.properties AS properties, c.description AS description,
- c.mangled_name AS mangled_name, IF(a.id IS NULL, 0, COUNT(*)) AS num_articles, a.date AS last_update
- FROM {$prefix}articles a
- LEFT JOIN {$prefix}articles_categories c ON c.id = l.category_id
- LEFT JOIN {$prefix}article_categories_link l ON a.id = l.article_id
+ c.mangled_name AS mangled_name, IF(a.id IS NULL, 0, COUNT(*)) AS num_articles, a.date AS last_update
+ FROM {$prefix}articles_categories c LEFT JOIN {$prefix}article_categories_link l
+ ON c.id=l.category_id LEFT JOIN {$prefix}articles a ON a.id = l.article_id
WHERE a.id IN (".$articleIds.") ";
if( $blogId > -1 ) {
$query .= " AND a.blog_id = '".Db::qstr( $blogId )."' AND c.blog_id = '".Db::qstr( $blogId )."'";
More information about the pLog-svn
mailing list