I simplified it a bit for you, if you don't mind.
public static function GetNewsItemByCategory($category,$limit)
{
$sql = 'SELECT *, UNIX_TIMESTAMP(postdate) AS postdate
FROM '.TABLE_PREFIX.'news WHERE category=`'.$category.'`';
if (!empty($limit))
{
$sql .= ' LIMIT '.$limit;
}
return DB::get_results($sql);
}
You can call it as (assuming you put it in SiteCMS, or even better, just create a new dataclass for it so it doesnt get overwritten - to do that just follow the same format as the other classes in there, ClassName.class.php, then inside that is class ClassName { }... in fact, creating a class like that called CustomQueries (so CustomQueries.class.php, and inside class CustomQueries{ } ) to put all your custom code so it's not overwritten in an update is probably a good idea)
$news = SiteCMS::getNewsItemByCategory($category, 1);