Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php class Model_Game extends ORM {
  2.    
  3.     public function listgames($a)
  4.     {
  5.         if ($a!='0')
  6.         {
  7.             $games = ORM::factory('game')
  8.                 ->where('genre', '=', $a)
  9.                 ->find_all();
  10.         }
  11.         else
  12.         {
  13.             $games = ORM::factory('game')->find_all();
  14.         }
  15.         return $games;
  16.     }
  17.    
  18.     public function fetchgame($id)
  19.     {
  20.         $game = ORM::factory('game',$id);
  21.         return $game;
  22.     }
  23.    
  24.     public static function unique_name($name)
  25.     {
  26.         // Check if the username already exists in the database
  27.         return ! DB::select(array(DB::expr('COUNT(name)'), 'total'))
  28.             ->from('games')
  29.             ->where('name', '=', $name)
  30.             ->execute()
  31.             ->get('total');
  32.     }
  33.    
  34.     public function searchgames($a)
  35.     {
  36.         $games = ORM::factory('game')
  37.             ->where ('name', 'LIKE', '%'.$a.'%')
  38.             ->or_where ('description', 'LIKE', '%'.$a.'%')
  39.             ->find_all();
  40.  
  41.         return $games;
  42.     }
  43.    
  44.     public function newest()
  45.     {
  46.         $games = ORM::factory('game')
  47.             ->order_by('id', 'DESC')
  48.             ->limit(10)
  49.             ->find_all();
  50.            
  51.         return $games;
  52.     }
  53.    
  54.  
  55. }
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement