/** * Returns the top read posts object of current blog */ function getTopReadPosts($maxPosts = 0, $based = 'BLOG') { $articles = new Articles(); $blogId = $this->blogInfo->getId(); if ($based == 'BLOG') { $query = "SELECT * FROM " . $this->prefix . "articles"; $query .= " WHERE blog_id = " . $blogId . " AND status = 1"; $query .= " ORDER BY num_reads DESC"; } elseif ($based == 'SITE') { $query = "SELECT * FROM " . $this->prefix . "articles"; $query .= " WHERE status = 1"; $query .= " ORDER BY num_reads DESC"; } else { return false; } if ($maxPosts > 0) { $query .= " LIMIT " . $maxPosts; } else { $query .= " LIMIT " . $this->maxPosts; } $result = $articles->_db->Execute($query); if (!$result) { return false; } $topreadposts = array(); while ($row = $result->FetchRow()) { $article = $articles->_fillArticleInformation($row); array_push($topreadposts, $article); } return $topreadposts; }
function getArticle($artId) { $articles = new Articles(); $blogId = $this->blogInfo->getId(); $query = "SELECT * FROM " . $this->prefix . "articles WHERE id = " . $artId; $query .= " AND blog_id = " . $blogId; $query .= ";"; // we send the query and then fetch the first array with the result $result = $articles->_db->Execute($query); if ($result == false) { return false; } if ($result->RecordCount() == 0) { return false; } $row = $result->FetchRow($result); $article = $articles->_fillArticleInformation($row); return $article; }
/** * * @param query * @param queryType Whether we got these results searching in the articles, comments, * or custom fields. * @private * @return */ function _getQueryResults($query, $queryType) { $result = $this->_db->Execute($query); // return an empty array if nothing available if (!$result) { return array(); } $results = array(); $articles = new Articles(); while ($row = $result->FetchRow()) { $article = $articles->_fillArticleInformation($row); $searchResult = new SearchResult($row["relevance"], $article, $queryType); // print_r(array_keys($row)); // print "<hr />"; array_push($results, $searchResult); } return $results; }