用户权限 - 子菜单

时间:2014-05-07 14:28:17

标签: php

我正在尝试执行查询以获取用户有权访问的子菜单

但我有一些问题。

我创建了此查询以获取菜单和子菜单

$query = ("SELECT menu_id, menu_friendlyname, name
        FROM menu 
        WHERE back = 1 AND active = 1");
    $menu = db_array($query, '++-'); //function that i created to facilitate my life, ignore

现在我试图只获取用户有权访问的子菜单

 $query = ("SELECT * FROM menu m LEFT JOIN submenu s USING(menu_id) WHERE s.active = 1 AND m.active = 1 AND m.back = 1 AND s.submenu_id IN ('". $submenu_ids ."')");
    $submenu = db_array($query, '+++-');

我从会话中获取submenu_ids

$submenu_ids = $_SESSION['user']['permissions_filter']['submenu_ids'];

我对查询做了回应,它似乎运作良好

SELECT * FROM menu m LEFT JOIN submenu s USING(menu_id) WHERE s.active = 1 AND m.active = 1 AND m.back = 1 AND s.submenu_id IN ('1,3,5,6')

我做错了什么?

感谢。

0 个答案:

没有答案