[pLog-svn] r3009 - plog/trunk/class/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Fri Mar 3 20:46:56 GMT 2006
Author: oscar
Date: 2006-03-03 20:46:55 +0000 (Fri, 03 Mar 2006)
New Revision: 3009
Modified:
plog/trunk/class/dao/articles.class.php
Log:
fixed getBlogPrevArticle and getBlogNextArticle, which were both generating an error in their SQL query
Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php 2006-03-03 10:36:36 UTC (rev 3008)
+++ plog/trunk/class/dao/articles.class.php 2006-03-03 20:46:55 UTC (rev 3009)
@@ -191,20 +191,13 @@
$articleCorrectedDate = Timestamp::getDateWithOffset( $article->getDate(),
-($article->getTimeOffset()));
- $whereConditions = array();
- // '=' is the default when calculating the where conditions, but to
- // have this look uniform, lets add the '=' anyway. :)
- $whereConditions['blog_id'] = '=' . $article->getBlogId();
- $whereConditions['date'] = '>' . $articleCorrectedDate;
- $whereConditions['status'] = '=' . POST_STATUS_PUBLISHED;
+ $query = "SELECT * FROM ".$this->getPrefix()."articles
+ WHERE blog_id = ".$article->getBlogId()." AND
+ date > ".$articleCorrectedDate." AND
+ status = ".POST_STATUS_PUBLISHED."
+ ORDER BY DATE ASC
+ LIMIT 0,1";
- $query = Db::buildSelectQuery( ARTICLES_TABLENAME,
- array(),
- $whereConditions,
- null,
- 'date',
- 1 );
-
$article = $this->_getBlogArticleFromQuery( $query, false );
return( $article );
@@ -224,22 +217,13 @@
$date = $article->getDateObject();
$articleCorrectedDate = Timestamp::getDateWithOffset( $article->getDate(),
-($article->getTimeOffset()));
- $blogId = $article->getBlog();
-
- $whereConditions = array();
- // '=' is the default when calculating the where conditions, but to
- // have this look uniform, lets add the '=' anyway. :)
- $whereConditions['blog_id'] = '=' . $article->getBlogId();
- $whereConditions['date'] = '<' . $articleCorrectedDate;
- $whereConditions['status'] = '=' . POST_STATUS_PUBLISHED;
-
- // gets the article that is just previous in time
- $query = Db::buildSelectQuery( ARTICLES_TABLENAME,
- array(),
- $whereConditions,
- null,
- 'date',
- 1 );
+
+ $query = "SELECT * FROM ".$this->getPrefix()."articles
+ WHERE blog_id = ".$article->getBlogId()." AND
+ date < ".$articleCorrectedDate." AND
+ status = ".POST_STATUS_PUBLISHED."
+ ORDER BY DATE DESC
+ LIMIT 0,1";
$article = $this->_getBlogArticleFromQuery( $query, false );
@@ -312,16 +296,16 @@
}
if( $date != -1 && $maxDate == 0 ) {
$postDate = substr($article->getDate(),0,strlen($date));
- if( $postDate != $date )
+ if( $postDate != $date ) {
return false;
+ }
}
elseif( $maxDate > 0 && $date != -1 ) {
$postDate = substr($article->getDate(),0,strlen($maxDate));
if( $postDate > $maxDate ) {
- return false;
+ return false;
}
}
-
return( true );
}
More information about the pLog-svn
mailing list