Skip to content

test code

Rayhan Uddin edited this page Oct 3, 2017 · 2 revisions
    $results = DB::select( DB::raw("select user,host from mysql.user;") );


    $result_prev = DB::select( DB::raw("show grants for root@localhost") );
     $CURRENT_USER = DB::select( DB::raw("SELECT USER()") );
     $grants = DB::select( DB::raw("SELECT * FROM information_schema.user_privileges") );
     $privileges = DB::select( DB::raw("show privileges") );
     $privileges2 = DB::select( DB::raw("SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user") 
      );
   $privileges_sub = DB::select( DB::raw("SHOW GRANTS FOR 'readonly'@'localhost'") );
   $privileges_sub_sub = DB::select( DB::raw("SHOW GRANTS FOR 'readonly'@'localhost'") );
  $privileges_sub_permission = DB::select( DB::raw("GRANT ALL PRIVILEGES ON ontiktec_ac.* TO 'root'@'localhost' WITH 
             GRANT OPTION") );
           $privileges_sub_permission = DB::select( DB::raw("CREATE USER 'username'@'localhost' IDENTIFIED BY 
              'somePassword'") );        

     $mysql = new mysqli();
  $stmt = $mysql->prepare('select * from information_schema.user_privileges');


   //*******
  // $results = DB::select( DB::raw("select * from mysql.user where user='readonly2' and host='localhost'"));
   $db= "readonly";
   $grants = DB::select( DB::raw("select * from information_schema.user_privileges where IS_GRANTABLE = 'no' and 
     grantee like '%$db%' "));
    $filter = [];
    foreach ($grants as $value){
        if($value->GRANTEE =="'$db'@'localhost'"){

            $filter[] = $value;
        }


    }
   dd($filter);
Clone this wiki locally