Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php class Model_Game extends ORM {
- public function listgames($a)
- {
- if ($a!='0')
- {
- $games = ORM::factory('game')
- ->where('genre', '=', $a)
- ->find_all();
- }
- else
- {
- $games = ORM::factory('game')->find_all();
- }
- return $games;
- }
- public function fetchgame($id)
- {
- $game = ORM::factory('game',$id);
- return $game;
- }
- public static function unique_name($name)
- {
- // Check if the username already exists in the database
- return ! DB::select(array(DB::expr('COUNT(name)'), 'total'))
- ->from('games')
- ->where('name', '=', $name)
- ->execute()
- ->get('total');
- }
- public function searchgames($a)
- {
- $games = ORM::factory('game')
- ->where ('name', 'LIKE', '%'.$a.'%')
- ->or_where ('description', 'LIKE', '%'.$a.'%')
- ->find_all();
- return $games;
- }
- public function newest()
- {
- $games = ORM::factory('game')
- ->order_by('id', 'DESC')
- ->limit(10)
- ->find_all();
- return $games;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement