Created
November 18, 2011 11:26
-
-
Save aquilax/1376219 to your computer and use it in GitHub Desktop.
application/classes/model/news.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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