Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PHP by pouya ( 9 years ago )
<?php 
    class Menus
    {
        public $id,$mname,$menuItems;
        public function __construct()
        {
            $this->db = new Connection();
            $this->db = $this->db->dbConnect();
        }
        public function GetMenus()
        {
            if(empty($name))
            {
                $menu = $this->db->prepare("select * from menu_nav");
                $menu->execute();
                $menu_array = array();
                while($row = $menu->fetch())
                {
                    $menu_array[] = $row;
                }
                return $menu_array;
            }
            else
            {
                header("Location: php/includes/errors/008.php");
                exit();
            }
        }
  public function SelectMenuById($id)
  {
   if(!empty($id))
   {
    $mnu = $this->db->prepare("select * from menu where id = ?");
    $mnu->bindParam(1,$id);
    $mnu->execute();
    $result = $mnu->fetch();

    $this->id = $result['id'];
    $this->mname = $result['name'];

    $mnu = $this->db->prepare("SELECT menu_items.id, menu_items.link FROM menu, menu_items WHERE  menu.id = ? AND menu_items.menu_id = menu.id;");
    $mnu->bindParam(1,$id);
    $mnu->execute();

    while($row = $mnu->fetch())
    {
     $this->menuItems[] = ["id" => $row['id'], "link" => $row['link']];
    }
   }
   else
   {
    header("Location: php/includes/errors/009.php");
    exit();
   }
  }
  public function DeleteMenu($id)
  {
   if(!empty($id))
   {
    $adm = $this->db->prepare("delete from menu_nav where id = ?");
    $adm->bindParam(1,$id);
    $adm->execute();
   }
   else
   {
    header("Location: php/includes/errors/010.php");
    exit();
   }
  }
  public function GetId()
  {
   return $this->id;
  }
  public function GetMenuName()
  {
   return $this->mname;
  }
  public function GetMenuItems()
  {
   return $this->menuItems;
  }
 }
?>

 

Revise this Paste

Your Name: Code Language: