Advertisement
Guest User

ArticlesCatsModel includes/model

a guest
Aug 6th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. <?php
  2.        
  3. class ArticlesCatsModel
  4. {
  5.        
  6.         public function Get($extra='')
  7.         {
  8.                 $cats = array();
  9.                 System::Get('db')->Execute("SELETE * FROM `articles_cats` {$extra}");
  10.                 if(System::Get('db')->AffectedRows()>0)
  11.                 {
  12.                         $cats = System::Get('db')->GetRows();
  13.                 }
  14.                 return $cats;
  15.        
  16.         }
  17.        
  18.         // return one article
  19.        
  20.         public function Get_By_Id($cid)
  21.         {
  22.                
  23.                
  24.         $cid = (int)$id;
  25.                 $cat = $this->Get("WHERE `cid`=$cid") ;
  26.                 return $cat[0];
  27.    
  28.  
  29.         }
  30.        
  31.  
  32.        
  33.         public function Add($data)
  34.         {
  35.                
  36.                 if(System::Get('db')->Insert('aticles_cats',$data)){
  37.                         return TRUE;
  38.                 }
  39.                 return FALSE;
  40.                
  41.         }
  42.        
  43.        
  44.         public function Update($cid,$data)
  45.        
  46.         {
  47.                 $cid=(int)$cid;
  48.                 if(System::Get('db')->Update('aticles_cats',$data,"WHERE `id` = $id")){
  49.                         return TRUE;
  50.                 }
  51.                 return FALSE;          
  52.                
  53.         }
  54.        
  55.         public function Delete($cid)
  56.        
  57.         {
  58.                
  59.                 $cid =(int)$cid;
  60.                 if(System::Get('db')->Delete('aticles_cats',"WHERE `cid` = $cid")){
  61.                         return TRUE;
  62.                 }
  63.                 return FALSE;
  64.                
  65.         }
  66.        
  67.                
  68.        
  69. }      
  70.        
  71. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement