Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // it should work with DB in direct way no filter etc...
- //this is var but must type it inside the class inside functions
- class ArticlesModel
- {
- public function Get($extra='')
- {
- $articles = array();
- System::Get('db')->Execute("SELETE * FROM `articles` {$extra}");
- if(System::Get('db')->AffectedRows()>0)
- {
- $articles = System::Get('db')->GetRows();
- }
- return $articles;
- }
- // return one article
- public function Get_By_Id($id)
- {
- $id = (int)$id;
- $article = $this->Get("WHERE `id`= $id") ;
- return $article;
- }
- //get catogery by id
- //return array
- public function Get_By_Cat($cid)
- {
- $cid = (int)$cid;
- return $this->Get("WHERE `cid` = $cid");
- }
- //Get last Articles
- public function Get_Last($num)
- {
- $num = (int)$num;
- return $this->Get("ORDER BY `id` DESC LIMIT $num");
- }
- public function Add($data)
- {
- if(System::Get('db')->Insert('aticles',$data)){
- return TRUE;
- }
- return FALSE;
- }
- public function Update($id,$data)
- {
- $id=(int)$id;
- if(System::Get('db')->Update('aticles',$data,"WHERE `id` = $id")){
- return TRUE;
- }
- return FALSE;
- }
- public function Delete($id)
- {
- $id =(int)$id;
- if(System::Get('db')->Delete('aticles',"WHERE `id` = $id")){
- return TRUE;
- }
- return FALSE;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement