Skip to content

Instantly share code, notes, and snippets.

@aquilax
Created November 18, 2011 11:26
Show Gist options
  • Save aquilax/1376219 to your computer and use it in GitHub Desktop.
Save aquilax/1376219 to your computer and use it in GitHub Desktop.
application/classes/model/news.php
<?php
/**
* Description of news
*
* @author aquilax
*/
class Model_News extends Model{
/*
* Load the news for the first page
*/
public function loadFirstPageNews($n){
return DB::select('id', 'title', 'user_id', 'user_name', 'comments', 'points', new Database_Expression('UNIX_TIMESTAMP(created) AS created'))
->from('news')
->order_by(new DatabaseExpression('(points - 1) / ((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(created))/3600 +2)^1.5'), 'DESC')
->order_by('created')
->limit($n)
->execute()
->as_array();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment