diff options
| author | Christian Fowler <spider@viovio.com> | 2006-01-25 18:56:19 +0000 |
|---|---|---|
| committer | Christian Fowler <spider@viovio.com> | 2006-01-25 18:56:19 +0000 |
| commit | b548033ac3b6af9927eea1018578a2853bbab0f7 (patch) | |
| tree | c056fa86f7c01a6142015d45582d2e88b2d9b20e | |
| parent | 80fa1d92b77ad11f70a395aac5eda8c019c70bcf (diff) | |
| download | articles-b548033ac3b6af9927eea1018578a2853bbab0f7.tar.gz articles-b548033ac3b6af9927eea1018578a2853bbab0f7.tar.bz2 articles-b548033ac3b6af9927eea1018578a2853bbab0f7.zip | |
fix ->fields calls
| -rw-r--r-- | BitArticle.php | 59 | ||||
| -rw-r--r-- | BitArticleTopic.php | 6 | ||||
| -rw-r--r-- | BitArticleType.php | 7 |
3 files changed, 32 insertions, 40 deletions
diff --git a/BitArticle.php b/BitArticle.php index 043dc99..df71750 100644 --- a/BitArticle.php +++ b/BitArticle.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticle.php,v 1.45 2006/01/25 15:40:23 spiderr Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticle.php,v 1.46 2006/01/25 18:56:19 spiderr Exp $ * @package article * * Copyright( c )2004 bitweaver.org @@ -9,14 +9,14 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: BitArticle.php,v 1.45 2006/01/25 15:40:23 spiderr Exp $ + * $Id: BitArticle.php,v 1.46 2006/01/25 18:56:19 spiderr Exp $ * * Article class is used when accessing BitArticles. It is based on TikiSample * and builds on core bitweaver functionality, such as the Liberty CMS engine. * * created 2004/8/15 * @author wolffy <wolff_borg@yahoo.com.au> - * @version $Revision: 1.45 $ $Date: 2006/01/25 15:40:23 $ $Author: spiderr $ + * @version $Revision: 1.46 $ $Date: 2006/01/25 18:56:19 $ $Author: spiderr $ */ /** @@ -104,23 +104,23 @@ class BitArticle extends LibertyAttachable { global $gBitSystem; if( $result && $result->numRows() ) { - $this->mInfo = $result->fields; + $this->mInfo = $result->fetchRow(); // if a custom image for the article exists, use that, then use an attachment, then use the topic image $this->mInfo['image_url'] = BitArticle::getImageUrl( $this->mInfo ); - $this->mContentId = $result->fields['content_id']; - $this->mArticleId = $result->fields['article_id']; - $this->mTopicId = $result->fields['topic_id']; - $this->mTypeId = $result->fields['article_type_id']; + $this->mContentId = $this->mInfo['content_id']; + $this->mArticleId = $this->mInfo['article_id']; + $this->mTopicId = $this->mInfo['topic_id']; + $this->mTypeId = $this->mInfo['article_type_id']; - $this->mInfo['creator'] = ( isset( $result->fields['creator_real_name'] )? $result->fields['creator_real_name'] : $result->fields['creator_user'] ); - $this->mInfo['editor'] = ( isset( $result->fields['modifier_real_name'] )? $result->fields['modifier_real_name'] : $result->fields['modifier_user'] ); + $this->mInfo['creator'] = ( isset( $this->mInfo['creator_real_name'] )? $this->mInfo['creator_real_name'] : $this->mInfo['creator_user'] ); + $this->mInfo['editor'] = ( isset( $this->mInfo['modifier_real_name'] )? $this->mInfo['modifier_real_name'] : $this->mInfo['modifier_user'] ); $this->mInfo['display_url'] = $this->getDisplayUrl(); $this->mInfo['parsed_data'] = $this->parseData( preg_replace( ARTICLE_SPLIT_REGEX, "", $this->mInfo['data'] )); /* get the "ago" time */ - $this->mInfo['time_difference'] = BitDate::calculateTimeDifference( $result->fields['publish_date'], NULL, $gBitSystem->getPreference( 'article_date_display_format' ) ); + $this->mInfo['time_difference'] = BitDate::calculateTimeDifference( $this->mInfo['publish_date'], NULL, $gBitSystem->getPreference( 'article_date_display_format' ) ); /* i think we don't need to parse the description when we load the full article. if( preg_match( ARTICLE_SPLIT_REGEX, $this->mInfo['data'] ) ) { @@ -598,29 +598,27 @@ class BitArticle extends LibertyAttachable { $find = $pParamHash['find']; if( @$this->verifyId( $pParamHash['topic_id'] ) ) { - $mid = "WHERE ta.`topic_id` = ? "; + $mid = " ta.`topic_id` = ? "; $bindvars[] = ( int )$pParamHash['topic_id']; } elseif( !empty( $pParamHash['topic'] ) ) { - $mid = "WHERE UPPER( top.`topic_name` ) = ? "; + $mid = " UPPER( top.`topic_name` ) = ? "; $bindvars[] = strtoupper( $pParamHash['topic'] ); } else { - $mid = "WHERE top.`active` != 'n' OR top.`active` IS NULL "; + $mid = " top.`active` != 'n' OR top.`active` IS NULL "; } if( is_array( $find ) ) { // you can use an array of articles - $mid = " WHERE tc.`title` IN( ".implode( ',',array_fill( 0, count( $find ),'?' ) )." )"; + $mid .= " AND tc.`title` IN( ".implode( ',',array_fill( 0, count( $find ),'?' ) )." )"; $bindvars = $find; } elseif( is_string( $find ) ) { // or a string - $mid = " WHERE UPPER( tc.`title` ) LIKE ? "; + $mid .= " AND UPPER( tc.`title` ) LIKE ? "; $bindvars = array( '%'.strtoupper( $find ).'%' ); } elseif( @$this->verifyId( $pParamHash['user_id'] ) ) { // or gate on a user - $mid = " WHERE tc.`creator_user_id` = ? "; + $mid .= " AND tc.`creator_user_id` = ? "; $bindvars = array( $pParamHash['user_id'] ); - } else { - $mid = ""; } if( @$this->verifyId( $pParamHash['status_id'] ) ) { @@ -642,22 +640,21 @@ class BitArticle extends LibertyAttachable { $bindvars[] = ( int )$timestamp; } - $query = "SELECT ta.*, tc.*, top.* , type.*, tas.`status_name`, - tf.`storage_path` as image_storage_path - FROM `".BIT_DB_PREFIX."tiki_articles` ta - INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON( tc.`content_id` = ta.`content_id` ) - INNER JOIN `".BIT_DB_PREFIX."tiki_article_status` tas ON( tas.`status_id` = ta.`status_id` ) - LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_article_topics` top ON( top.`topic_id` = ta.`topic_id` ) - LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_article_types` type ON( type.`article_type_id` = ta.`article_type_id` ) - LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_attachments` tat ON( tat.`attachment_id` = ta.`image_attachment_id` ) - LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_files` tf ON( tf.file_id = tat.foreign_id ) - ". $mid ." AND tc.`content_type_guid` = '".BITARTICLE_CONTENT_TYPE_GUID."' - ORDER BY ".$this->mDb->convert_sortmode( $pParamHash['sort_mode'] ); + $query = "SELECT ta.*, tc.*, top.* , type.*, tas.`status_name`, tf.`storage_path` as image_storage_path + FROM `".BIT_DB_PREFIX."tiki_articles` ta + INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON( tc.`content_id` = ta.`content_id` ) + INNER JOIN `".BIT_DB_PREFIX."tiki_article_status` tas ON( tas.`status_id` = ta.`status_id` ) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_article_topics` top ON( top.`topic_id` = ta.`topic_id` ) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_article_types` type ON( type.`article_type_id` = ta.`article_type_id` ) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_attachments` tat ON( tat.`attachment_id` = ta.`image_attachment_id` ) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_files` tf ON( tf.file_id = tat.foreign_id ) + WHERE ". $mid ." AND tc.`content_type_guid` = '".BITARTICLE_CONTENT_TYPE_GUID."' + ORDER BY ".$this->mDb->convert_sortmode( $pParamHash['sort_mode'] ); $query_cant = "SELECT COUNT( * )FROM `".BIT_DB_PREFIX."tiki_articles` ta INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON( tc.`content_id` = ta.`content_id` ) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_article_topics` top ON( top.`topic_id` = ta.`topic_id` ) - ".( !empty( $mid )? $mid.' AND ' : ' WHERE ' )." tc.`content_type_guid` = '".BITARTICLE_CONTENT_TYPE_GUID."'"; + WHERE tc.`content_type_guid` = '".BITARTICLE_CONTENT_TYPE_GUID."' AND " . $mid ; $result = $this->mDb->query( $query, $bindvars, $pParamHash['max_records'], $pParamHash['offset'] ); $ret = array(); diff --git a/BitArticleTopic.php b/BitArticleTopic.php index 9117fb2..1c01a2e 100644 --- a/BitArticleTopic.php +++ b/BitArticleTopic.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticleTopic.php,v 1.16 2006/01/10 21:11:08 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticleTopic.php,v 1.17 2006/01/25 18:56:19 spiderr Exp $ * @package article */ @@ -42,9 +42,7 @@ class BitArticleTopic extends BitBase { $sql = "SELECT at.*". "FROM `".BIT_DB_PREFIX."tiki_article_topics` at ". $whereSQL; - $rs = $this->mDb->query($sql, $bindVars); - - $this->mInfo = $rs->fields; + $this->mInfo = $this->mDb->getRow($sql, $bindVars); $this->mTopicId = $this->mInfo['topic_id']; if ($this->mInfo['has_topic_image']) { diff --git a/BitArticleType.php b/BitArticleType.php index 398a236..9518a6a 100644 --- a/BitArticleType.php +++ b/BitArticleType.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticleType.php,v 1.9 2006/01/10 21:11:08 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticleType.php,v 1.10 2006/01/25 18:56:19 spiderr Exp $ * @package article */ @@ -38,11 +38,8 @@ class BitArticleType extends BitBase if ($this->mTypeId) { $sql = "SELECT * FROM `".BIT_DB_PREFIX."tiki_article_types` WHERE `article_type_id` = ?"; - $rs = $this->mDb->query($sql, array($this->mTypeId)); - $ret = array(); - if (!empty($rs->fields)) { - $ret = $rs->fields; + if( $ret = $this->mDb->getRow($sql, array($this->mTypeId)) ) { $ret['num_articles'] = $this->mDb->getOne('SELECT COUNT(*) FROM `'.BIT_DB_PREFIX.'tiki_articles` WHERE `article_type_id` = ?', array($ret['article_type_id'])); } } |
