[pLog-svn] r945 - plog/trunk/class/dao
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Fri Feb 4 18:15:54 GMT 2005
Author: oscar
Date: 2005-02-04 18:15:54 +0000 (Fri, 04 Feb 2005)
New Revision: 945
Modified:
plog/trunk/class/dao/articles.class.php
Log:
fixed issue 208 according to jon's suggestion (http://bugs.plogworld.net/bug_view_advanced_page.php?bug_id=208)
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2005-02-04 10:42:17 UTC (rev 944)
+++ plog/trunk/class/dao/articles.class.php 2005-02-04 18:15:54 UTC (rev 945)
@@ -94,11 +94,18 @@
*/
function getBlogArticle( $artId, $blogId = -1, $includeHiddenFields = true, $date = -1, $categoryId = -1, $userId = -1, $status = POST_STATUS_ANY )
{
+ $prefix = $this->getPrefix();
$query = "SELECT a.id, a.date,
a.user_id,a.blog_id,a.status,a.properties,
- a.num_reads, a.slug FROM ".$this->getPrefix()."articles a, ".$this->getPrefix()."articles_categories c, ".
- $this->getPrefix()."article_categories_link l
- WHERE a.id = ".Db::qstr($artId);
+ a.num_reads, a.slug FROM {$prefix}articles a ";
+ // thanks jon for the tip :) You're right that the amount of rows will be too big if we don't really need these
+ // fields!
+ if($categoryId != -1 && $blogId != -1) {
+ $query .= ", {$prefix}articles_categories c, {$prefix}article_categories_link l ";
+ }
+
+ $query .= "WHERE a.id = ".Db::qstr($artId);
+
if( $blogId != -1 )
$query .= " AND a.blog_id = ".Db::qstr($blogId);
if( $date != -1 )
@@ -126,9 +133,12 @@
$prefix = $this->getPrefix();
$query = "SELECT a.id, a.date,
a.user_id,a.blog_id,a.status,a.properties,
- a.num_reads, a.slug FROM {$prefix}articles a, {$prefix}articles_categories c,
- {$prefix}article_categories_link l
- WHERE a.slug = '".Db::qstr($artTitle)."'";
+ a.num_reads, a.slug FROM {$prefix}articles a ";
+ // thanks jon once again :)
+ if($categoryId != -1 && $blogId != -1) {
+ $query .= ",{$prefix}articles_categories c, {$prefix}article_categories_link l ";
+ }
+ $query .= "WHERE a.slug = '".Db::qstr($artTitle)."'";
if( $blogId != -1 )
$query .= " AND a.blog_id = ".Db::qstr($blogId);
if( $date != -1 )
More information about the pLog-svn
mailing list