posts} AS p INNER JOIN {$oDb->post2cat} AS c ON p.ID = c.post_ID";
$sQuery .= " WHERE c.category_id {$mCategoryId} AND p.post_status = 'publish'";
if ($bRandomise) {
$sQuery .= " ORDER BY RAND()";
} else {
$sQuery .= " ORDER BY p.ID";
}
if ($bAscending) {
$sQuery .= " ASC";
} else {
$sQuery .= " DESC";
}
if ($iLimit > 0) {
$sQuery .= " LIMIT 0, {$iLimit}";
}
$rQuery = mysql_query($sQuery);
$aResults = array();
while ($oResult = mysql_fetch_object($rQuery)) {
$aResults[] = $oResult;
}
return $aResults;
}
function printAsListItems ($iCategoryId, $iLimit = 5, $bAscendingSort = false, $bRandomise = true) {
$aResults = DBPostsForCategory :: getResults($iCategoryId, $iLimit, $bAscendingSort, $bRandomise);
if (!is_array($aResults)) {
return "";
}
foreach ($aResults as $oResult) {
echo "
";
printf('%s', get_permalink($oResult->post_id), $oResult->post_title);
echo "\n";
}
}
function printAsExcerptItems ($iCategoryId, $iLimit = 5, $bAscendingSort = false, $bRandomise = false) {
$aResults = DBPostsForCategory :: getResults($iCategoryId, $iLimit, $bAscendingSort, $bRandomise);
if (!is_array($aResults)) {
return "";
}
foreach ($aResults as $oResult) {
printf('\n";
}
}
function printAllRelatedPostsAsListItems ($aCategories, $iLimit = 5, $bAscendingSort = false, $bRandomise = true) {
$aCatIds = array();
foreach ($aCategories as $oCategory) {
$aCatIds[] = $oCategory->cat_ID;
}
$aResults = DBPostsForCategory :: getResults($aCatIds, $iLimit, $bAscendingSort, $bRandomise);
if (!is_array($aResults)) {
return "";
}
foreach ($aResults as $oResult) {
echo "";
printf('%s', get_permalink($oResult->post_id), $oResult->post_title);
echo "\n";
}
}
}
?>