From d526decc4884710ae7fafe7aa5171e7f59b24292 Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sun, 27 Dec 2009 15:44:57 +0000 Subject: MySQL -> MySQLi Fixed memory leaks after Fetching arrays Removed all while loops that interfaced with $db->Fetch() Rewrote RSS module Fixed syntax error in donations module Fixed link structure for news module Reverting to old page display method git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@402 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- modules/news/functions.php | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'modules/news/functions.php') diff --git a/modules/news/functions.php b/modules/news/functions.php index b76a53e..bd901aa 100644 --- a/modules/news/functions.php +++ b/modules/news/functions.php @@ -31,13 +31,15 @@ function getNewsComments($id){ "LEFT OUTER JOIN `mybb_users` AS u ON u.uid = c.author_id ". "WHERE c.news_id = '$id' ". "ORDER BY date ASC"); + $comments = $db->Fetch($result); + /* while(($row = $db->Fetch($result)) != false) { $comments[] = $row; } $db->Free($result); - + */ return $comments; } @@ -117,7 +119,7 @@ function getNumOfComments($id){ global $db; $result = $db->Query("SELECT `comment_id` FROM `bayonet_news_comments` WHERE `news_id` = '$id'"); - return $db->Rows($result);; + return $db->Rows($result); } /** @@ -142,12 +144,18 @@ function getNews($id = NULL){ } $result = $db->Query($query); + $data = $db->Fetch($result); + //decho($data); + // {{{ XXX: FIXME -- Re-write + /* while(($row = $db->Fetch($result)) != false) { $data[] = $row; } $db->Free($result); + */ + // }}} return $data; } @@ -160,10 +168,12 @@ function getNews($id = NULL){ function displayNews($data){ date_default_timezone_set("America/New_York"); + + foreach($data as $news) - { + { $numComments = getNumOfComments($news['news_id']); - + //echo "
".print_r($news,true)."
"; OpenContent(); ?>
@@ -177,12 +187,12 @@ function displayNews($data){
<?php echo $news['catname']; ?> -
+
@@ -192,7 +202,8 @@ function displayNews($data){ "; - } + + } } /** This was coded on Coda with a MacBook Pro **/ @@ -212,6 +223,8 @@ function commentForm(){ $cur_user_id = 0; //testing variable, until i get the login system working for this $logged_in = false; + // {{{ XXX: FIXME -- Re-write this + /* $result = $db->Query("SELECT `username`, `avatar` FROM `mybb_users` WHERE `uid` = '$cur_user_id' LIMIT 1"); while(($row = $db->Fetch($result)) != false) { @@ -219,7 +232,8 @@ function commentForm(){ $avatar = $row['avatar']; $logged_in = true; } - + */ + // }}} ?>

Add Your Comment

@@ -257,4 +271,4 @@ function commentForm(){ \ No newline at end of file +?> -- cgit
- View Comments: Comments + View Comments: Comments Posted on: