<?php
//===GET===

$sql['get_data_group'] = 
   "SELECT 
      GroupId AS id,
      GroupName AS name,
      Description AS group_description
   FROM 
      gtfw_group
   WHERE
      GroupName like '%s' 
   /*AND 
      GroupId != '2'*/
   ORDER BY 
      GroupName";
   
$sql['get_data_group_with_privilege'] = 
   "SELECT 
      g.GroupId AS group_id,
      g.GroupName AS group_name,
      g.Description AS group_description,
      GROUP_CONCAT(`MenuId` ORDER BY `MenuName` SEPARATOR '|') AS `menu_id`,
      GROUP_CONCAT(`MenuName` ORDER BY `MenuName` SEPARATOR '|') AS `menu_name`,
      GROUP_CONCAT(`ParentMenuId` ORDER BY `MenuName` SEPARATOR '|') AS `parent_menu`
   FROM 
      gtfw_group g
      LEFT JOIN gtfw_group_menu gm ON g.GroupId=gm.GroupId
   WHERE
      GroupName like '%s' /*AND g.GroupId>2*/
   GROUP BY g.GroupId
   ORDER BY GroupName";   
   
$sql['get_data_group_by_id']= 
   "SELECT 	
	    g.GroupId AS group_id,
      g.GroupName AS group_name,
      g.Description AS group_description,
      GROUP_CONCAT(`MenuId` ORDER BY `MenuName` SEPARATOR '|') AS `menu_id`,
      GROUP_CONCAT(`MenuName` ORDER BY `MenuName` SEPARATOR '|') AS `menu_name`,
      GROUP_CONCAT(`ParentMenuId` ORDER BY `MenuName` SEPARATOR '|') AS `parent_menu`
   FROM 
    	gtfw_group g
    	LEFT JOIN gtfw_group_menu gm ON g.GroupId=gm.GroupId
   WHERE
	    g.GroupId = '%s'
   GROUP BY g.GroupId";

$sql['get_last_group_id'] = 
   "SELECT MAX(GroupId) 
      FROM gtfw_group;";

//===DO===
$sql['do_add_group'] = 
   "INSERT INTO gtfw_group 
      (GroupName, Description)
   VALUES
      ('%s','%s')";
 
$sql['do_update_group'] =
   "UPDATE gtfw_group
   SET 
      GroupName='%s',
      Description='%s'
   WHERE 
      GroupId='%s'";
   
$sql['do_delete_group'] = 
   "DELETE FROM gtfw_group
   WHERE GroupId = '%s'";

?>
