Stacks

 

Whenever i get time from my work or personal life I try to solve the questions posted in Stacksoverflow. It help me to keep update every time. As there are big brains out their who implement new things or do the same thing in some interesting ways.  And also I can recall and share few implementation of my self answering related questions.

And YES….I do also ask question whenever i done with enough googling. The best thing in stack is it will provide correct answer within few minutes and only correct answers are promoted by the users.

My account link : Suresh Kamrushi
Listing below some of the questions and answer in which i have participated.

User Suresh Kamrushi - Stack Overflow

most recent 30 from stackoverflow.com

what you have tried so far
Author: Suresh Kamrushi
Posted: March 18, 2019, 7:18 am

You can do like below:

$(".actionEdit").on("click", function () {
        var uniqueId = $(this).attr("data-id");
        $.ajax({
            url: "path",
            type: 'POST',
            data: { uniqueId: uniqueId },
            success: function (result) {
                 //do something with result
                 $('#update').modal('show');  //open the modal window
            },
            error: function () { alert("Whooaaa! Something went wrong.."); }
        });

    });

Provide a class as "actionEdit" and bind the click event to it. And on click you can get the data-id and make a ajax call to get all values for edit/update and open the modal window.

Author: Suresh Kamrushi
Posted: March 18, 2019, 7:15 am
what you have tried so far?
Author: Suresh Kamrushi
Posted: March 18, 2019, 6:51 am

You can try like this:

$json = '{"fileName":null,"fileUrl":["U2FsdGVkX1-uM6l4RxCWpIiXiCglblQ45V61bTVvuRC2H3ru72DjM0I337iegtL0eG7-t_H_CEeMrc3vopGkVA","U2FsdGVkX19AX2GGMh_dy71pYYNjgI5Dp1doC58zYqbZbjz02KWdVn5BXjiLcOqjLcgHgKFiOvLQXbRMTzVMJUATPQGh-zMmWaUtUJ0gveLvKOaX3FkM33ZrblwISSBZeocZHxIVxOR1jFpUf9HmuQ","U2FsdGVkX1_XwHvpVBapqhs4fw-6SlUcF8U7rXFxdWTBWeKU7mxQwi1rh9Hor4wPLhQub_qFIprhH59iM90CGsiomMuRmv6cfFBrDzIUkyIEUf83-uBin8L6SWGoyZrQpB6jdAt_elGnS3lYp-TUGg","U2FsdGVkX1-dlLo5wNZpACpERA7aJz-hzegQZ7VGl_uSn9fle1ykAud-ax2kqVhYsmDMJoYbogX9--WFFhAkXCoulHX2wGeD1_N1uvoZvd6-B-4EBmwguntVKHZo3BExZCz0OmRG65gBBXCcV7M10g","U2FsdGVkX1-11v5vUHoO1Yx7Pbsz1OgR4PkmFMHBcw2YO6gQanKg6NL6jLUVF1AqOK5nmTAazur7SZtjIRatJ3_NVR7Q4ya7rZbkXdEIslJKp6hpkgASbJ1hUAWKoNgjoxUEs2FclnQyiTDHntlCUQ"],"categoryId":"1110"}';

$jsonObj = json_decode($json);

echo $jsonObj->fileUrl[0];
Author: Suresh Kamrushi
Posted: March 18, 2019, 6:30 am
What you have tried so far?
Author: Suresh Kamrushi
Posted: March 18, 2019, 6:20 am
share your looping code. add more details
Author: Suresh Kamrushi
Posted: March 18, 2019, 6:06 am

You can use convert with date and datetime as below:

SELECT convert(datetime, '27-09-2013', 104)
SELECT convert(date, '27-09-2013', 104)
Author: Suresh Kamrushi
Posted: March 12, 2019, 7:22 am

You can do like this:

SELECT convert(datetime, convert(date, '27-09-2013', 103), 103) 
Author: Suresh Kamrushi
Posted: March 12, 2019, 7:18 am

try the following SQL query to achieve the expected result:

SELECT convert(varchar, convert(date, '27-09-2013 16:15:00', 105), 101) 
Author: Suresh Kamrushi
Posted: March 12, 2019, 7:15 am
I dont know why but it works for me!!
Author: Suresh Kamrushi
Posted: February 13, 2019, 5:51 am

You can do something like below which work for me:

//To align center
sheetcreate.Cells[1, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

//To align right
eachRowObject.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
Author: Suresh Kamrushi
Posted: January 29, 2019, 8:46 am
work perfectly!!!
Author: Suresh Kamrushi
Posted: January 21, 2019, 8:23 am
You must do basic research before you post.
Author: Suresh Kamrushi
Posted: December 4, 2018, 5:35 am
Author: Suresh Kamrushi
Posted: December 4, 2018, 5:34 am
Did you tried what i have answered?
Author: Suresh Kamrushi
Posted: November 29, 2018, 5:39 am
I assume you need to perform on "Procced" id
Author: Suresh Kamrushi
Posted: November 29, 2018, 5:29 am

You can do somethig like this:

    $( document ).ready(function() {
      //Assuming you need to perform on "procced" id click
        $("#procced").click(function(){ 
          $( ".options" ).each(function() {
           if(!$( this ).is(':visible')) {
             $( this ).show()
             break; //break the loop
           }
         });
     });
});
Author: Suresh Kamrushi
Posted: November 29, 2018, 5:19 am

You can try something like below:

public void readXLS(string FilePath)
{
    FileInfo existingFile = new FileInfo(FilePath);
    using (ExcelPackage package = new ExcelPackage(existingFile))
    {
        //get the first worksheet in the workbook
        ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
        int colCount = worksheet.Dimension.End.Column;  //get Column Count
        int rowCount = worksheet.Dimension.End.Row;     //get row count
        for (int row = 1; row <= rowCount; row++)
        {
            for (int col = 1; col <= colCount; col++)
            {
                Console.WriteLine(" Row:" + row + " column:" + col + " Value:" + worksheet.Cells[row, col].Value.ToString().Trim());
            }
        }
    }
}

Reff: http://sforsuresh.in/reading-excel-file-using-epplus-package/

Author: Suresh Kamrushi
Posted: November 13, 2018, 10:17 am

You can try something like this:

public string excelParsing(string fullpath)
{
    string data = "";
    //Create COM Objects. Create a COM object for everything that is referenced
    Excel.Application xlApp = new Excel.Application();
    Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(fullpath);
    Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
    Excel.Range xlRange = xlWorksheet.UsedRange;

    int rowCount = xlRange.Rows.Count;
    int colCount = xlRange.Columns.Count;

    //iterate over the rows and columns and print to the console as it appears in the file
    //excel is not zero based!!
    for (int i = 1; i <= rowCount; i++)
    {
        for (int j = 1; j <= colCount; j++)
        {
             //either collect data cell by cell or DO you job like insert to DB 
            if (xlRange.Cells[i, j] != null && xlRange.Cells[i, j].Value2 != null)
                data += xlRange.Cells[i, j].Value2.ToString();
        }
    }

    return data;
}

http://sforsuresh.in/how-to-read-an-excel-file-using-asp-net-mvc4/

Author: Suresh Kamrushi
Posted: November 13, 2018, 10:16 am

A sample code:

public string excelParsing(string fullpath)
{
    string data = "";
    //Create COM Objects. Create a COM object for everything that is referenced
    Excel.Application xlApp = new Excel.Application();
    Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(fullpath);
    Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
    Excel.Range xlRange = xlWorksheet.UsedRange;

    int rowCount = xlRange.Rows.Count;
    int colCount = xlRange.Columns.Count;

    //iterate over the rows and columns and print to the console as it appears in the file
    //excel is not zero based!!
    for (int i = 1; i <= rowCount; i++)
    {
        for (int j = 1; j <= colCount; j++)
        {
             //either collect data cell by cell or DO you job like insert to DB 
            if (xlRange.Cells[i, j] != null && xlRange.Cells[i, j].Value2 != null)
                data += xlRange.Cells[i, j].Value2.ToString();
        }
    }

    return data;
}

For detail description : http://sforsuresh.in/how-to-read-an-excel-file-using-asp-net-mvc4/

Author: Suresh Kamrushi
Posted: November 13, 2018, 10:14 am
Work for me!! thanks
Author: Suresh Kamrushi
Posted: November 9, 2018, 6:00 am

Below is the function which will upload the images to specific folder. You can all below function like:

Param 1: is the folder where we need to store the new image  
Param 2: is FILES  
Param 3: if any prefix for the image we need to pass it.  
Param 4: if there is any previously uploaded image for same record. It should be deleted from the folder. Generally it is usefull when you are editing particluar record.  

uploadfile("profile",$_FILES,"profile_pic");

Code is here:

 function uploadfile($folder,$data,$preFix = "logo_",$previousImage="") {
        $location = (pathinfo($_SERVER['SCRIPT_FILENAME']));
        $uploads_dir = $location['dirname'] . "/assets/uploads/" . $folder . "/";
        $fileNames = "";
        $tmp_name = $data["tmp_name"];
        $name = $data["name"];
        $fileExtension = pathinfo($name, PATHINFO_EXTENSION);
        $newfilename = $preFix . date("ymdhms") . '.' . $fileExtension;
        $fulldest = $uploads_dir . $newfilename;
        if (move_uploaded_file($tmp_name, $fulldest)) {
            if($previousImage != "")
                $this->removePreviousImage($folder, $previousImage);     //deleting existing image
            return $newfilename;
        } else {
            exit("Error File Uploading");
        }
    }
Author: Suresh Kamrushi
Posted: November 5, 2018, 10:24 am
Storing image in table is bad idea
Author: Suresh Kamrushi
Posted: November 5, 2018, 8:53 am

You can do like this:

excel.Workbook.Properties.Title = "Attempts";
this.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
this.Response.AddHeader("content-disposition",string.Format("attachment;  filename={0}", "ExcellData.xlsx"));
this.Response.BinaryWrite(excel.GetAsByteArray());

For detailed blog: http://sforsuresh.in/generating-and-formatting-excelsheet-in-c-using-epplus/

Author: Suresh Kamrushi
Posted: November 2, 2018, 10:34 am

You can install package from "Package Manager condole" like below: For specific verrsion

PM > Install-Package EPPlus -Version 4.5.2.1 

without version

PM > Install-Package EPPlus

Generating excel refer blog: http://sforsuresh.in/generating-and-formatting-excelsheet-in-c-using-epplus/

Author: Suresh Kamrushi
Posted: November 2, 2018, 10:31 am
does not work for sql
Author: Suresh Kamrushi
Posted: October 15, 2018, 1:14 pm
work like a charm!! Thanks
Author: Suresh Kamrushi
Posted: October 15, 2018, 10:14 am

The type or namespace name 'Server' could not be found (are you missing a using directive or an assembly reference?)

string connetionString = @"connectionStirng"; 
SqlConnection conn = new SqlConnection(connetionString); 
var server = new Server(new ServerConnection(conn));

added at the top

using Microsoft.SqlServer.Management.Common;

Still giving error.
Any help appricated.

Already checked:
Why i'm getting error for the Microsoft.SqlServer.Server namespace?
I can't add Microsoft.SqlServer.Management.Common to my ASP.NET MVC Application

enter image description here

Author: Suresh Kamrushi
Posted: October 11, 2018, 9:04 am

few options like:
1) instead of passing in url post the data.
2) encode while passing through url and decode while updating

Author: Suresh Kamrushi
Posted: September 28, 2018, 5:22 am

None of the above work for me, so sharing what works actually Go to your file "ProjectInstaller.Designer.cs" and upadate the line:

this.serviceInstaller1.ServiceName = "Updated Name";

It should be under method: InitializeComponent()

Hope it helps someone!!!

Author: Suresh Kamrushi
Posted: September 27, 2018, 9:46 am

You can fixed by either of below steps:
Option 1: To Resolve issue you have to move “System.Web.Http.WebHost.dll” file in “bin” folder to IIS. And restart the server to reload everything again. Check the site should work.

Option 2: Follow below steps:
1) Go to “Solution Explorer” in Visula Studio.
2) Right Click on “System.Web.Http.WebHost” in “References” and select properties.
3) Update property “Local Copy” to “True”.
4) Clear and Build again to have DLL in bin folder.
5) Copy the “System.Web.Http.WebHost.dll” file in “bin” folder to IIS.
Application should work.

Source: http://sforsuresh.in/not-load-file-assembly-system-web-http-webhost/

Author: Suresh Kamrushi
Posted: September 17, 2018, 10:48 am

If you are not able to find php.ini file then alternatively you can update the ini setting using below code, which can be added at the top of PHP file or your config file if you have.

<?php
echo ini_get('ConfigName');

if (!ini_get('ConfigName')) {
ini_set('ConfigName', 'SomeValue');
}
?>

ConfigName : will be setting name which you want to update in php.ini.
More info: http://php.net/manual/en/function.ini-set.php

Author: Suresh Kamrushi
Posted: September 14, 2018, 11:22 am

You can try like this:

update table set `count` = `count` + 1 

Above query will update all rows.
If you want to update specific row you can add where condition:

update table set `count` = `count` + 1 where name = 'searchText'
Author: Suresh Kamrushi
Posted: September 10, 2018, 12:11 pm

You can try this:

    $query = "select * from plan where plan.plan_id NOT IN (select task.plan_name_id from task)"
    $res= $this->db->query($query);
Author: Suresh Kamrushi
Posted: September 10, 2018, 11:30 am

Follow below steps to start/stop window services:

1) To access windows service you need to add below namespace in your controller:

using System.ServiceProcess;

If you are getting error as “namespace name ‘ServiceController’ could not be found” while adding above namesapce you need to add using “Add Reference”. For more details see my blog HERE

2) Add below code to your controller:

ServiceController service = new ServiceController("Test Windows Service");
service.Start();

It will start your services. Source: http://sforsuresh.in/starting-windows-services-c-mvc-4/

Author: Suresh Kamrushi
Posted: September 4, 2018, 11:17 am

You can do like this:

public bool readXLS(string FilePath)
{
    FileInfo existingFile = new FileInfo(FilePath);
    using (ExcelPackage package = new ExcelPackage(existingFile))
    {
        //get the first worksheet in the workbook
        ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
        int colCount = worksheet.Dimension.End.Column;  //get Column Count
        int rowCount = worksheet.Dimension.End.Row;     //get row count
        string queryString = "INSERT INTO tableName VALUES";        //Here I am using "blind insert". You can specify the column names Blient inset is strongly not recommanded
        string eachVal = "";
        bool status;
        for (int row = 1; row <= rowCount; row++)
        {
            queryString += "(";
            for (int col = 1; col <= colCount; col++)
            {
                eachVal = worksheet.Cells[row, col].Value.ToString().Trim();
                queryString += "'" + eachVal + "',";
            }
            queryString = queryString.Remove(queryString.Length - 1, 1);    //removing last comma (,) from the string
            if (row % 1000 == 0)        //On every 1000 query will execute, as maximum of 1000 will be executed at a time. 
            {
                queryString += ")";
                status = this.runQuery(queryString);    //executing query
                if (status == false)
                    return status;
                queryString = "INSERT INTO tableName VALUES";
            }
            else
            {
                queryString += "),";
            }
        }
        queryString = queryString.Remove(queryString.Length - 1, 1);    //removing last comma (,) from the string
        status = this.runQuery(queryString);    //executing query
        return status;
    }
}

Source: http://sforsuresh.in/read-data-excel-sheet-insert-database-table-c/

Author: Suresh Kamrushi
Posted: September 4, 2018, 10:48 am

Mysql version 5.0.3 varchar can store maximum of 65,535 characters.
But again this limit is having limitation of maximum row size which is 65535 bytes. It means including all columns it should be less than 65,535 bytes.

Detailed blog: http://sforsuresh.in/mysql_varchar_max_length/

Author: Suresh Kamrushi
Posted: September 4, 2018, 9:17 am

you can do like this:

public bool readXLS(string FilePath)
{
    FileInfo existingFile = new FileInfo(FilePath);
    using (ExcelPackage package = new ExcelPackage(existingFile))
    {
        //get the first worksheet in the workbook
        ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
        int colCount = worksheet.Dimension.End.Column;  //get Column Count
        int rowCount = worksheet.Dimension.End.Row;     //get row count
        string queryString = "INSERT INTO tableName VALUES";        //Here I am using "blind insert". You can specify the column names Blient inset is strongly not recommanded
        string eachVal = "";
        bool status;
        for (int row = 1; row <= rowCount; row++)
        {
            queryString += "(";
            for (int col = 1; col <= colCount; col++)
            {
                eachVal = worksheet.Cells[row, col].Value.ToString().Trim();
                queryString += "'" + eachVal + "',";
            }
            queryString = queryString.Remove(queryString.Length - 1, 1);    //removing last comma (,) from the string
            if (row % 1000 == 0)        //On every 1000 query will execute, as maximum of 1000 will be executed at a time. 
            {
                queryString += ")";
                status = this.runQuery(queryString);    //executing query
                if (status == false)
                    return status;
                queryString = "INSERT INTO tableName VALUES";
            }
            else
            {
                queryString += "),";
            }
        }
        queryString = queryString.Remove(queryString.Length - 1, 1);    //removing last comma (,) from the string
        status = this.runQuery(queryString);    //executing query
        return status;
    }
}

Details: http://sforsuresh.in/read-data-excel-sheet-insert-database-table-c/

Author: Suresh Kamrushi
Posted: August 30, 2018, 11:39 am

A simple example here:
Reff: http://sforsuresh.in/read-data-excel-sheet-insert-database-table-c/

public bool readXLS(string FilePath)
{
    FileInfo existingFile = new FileInfo(FilePath);
    using (ExcelPackage package = new ExcelPackage(existingFile))
    {
        //get the first worksheet in the workbook
        ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
        int colCount = worksheet.Dimension.End.Column;  //get Column Count
        int rowCount = worksheet.Dimension.End.Row;     //get row count
        string queryString = "INSERT INTO tableName VALUES";        //Here I am using "blind insert". You can specify the column names Blient inset is strongly not recommanded
        string eachVal = "";
        bool status;
        for (int row = 1; row <= rowCount; row++)
        {
            queryString += "(";
            for (int col = 1; col <= colCount; col++)
            {
                eachVal = worksheet.Cells[row, col].Value.ToString().Trim();
                queryString += "'" + eachVal + "',";
            }
            queryString = queryString.Remove(queryString.Length - 1, 1);    //removing last comma (,) from the string
            if (row % 1000 == 0)        //On every 1000 query will execute, as maximum of 1000 will be executed at a time. 
            {
                queryString += ")";
                status = this.runQuery(queryString);    //executing query
                if (status == false)
                    return status;
                queryString = "INSERT INTO tableName VALUES";
            }
            else
            {
                queryString += "),";
            }
        }
        queryString = queryString.Remove(queryString.Length - 1, 1);    //removing last comma (,) from the string
        status = this.runQuery(queryString);    //executing query
        return status;
    }
}
Author: Suresh Kamrushi
Posted: August 23, 2018, 11:02 am

Here I am sharing how you can read the excel. You can modify it to store each date in datatables.

public void readXLS(string FilePath)
{
    FileInfo existingFile = new FileInfo(FilePath);
    using (ExcelPackage package = new ExcelPackage(existingFile))
    {
        //get the first worksheet in the workbook
        ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
        int colCount = worksheet.Dimension.End.Column;  //get Column Count
        int rowCount = worksheet.Dimension.End.Row;     //get row count
        for (int row = 1; row <= rowCount; row++)
        {
            for (int col = 1; col <= colCount; col++)
            {
                //You can update code here to add each cell value to DataTable.
                Console.WriteLine(" Row:" + row + " column:" + col + " Value:" + worksheet.Cells[row, col].Value.ToString().Trim());
            }
        }
    }
}

Reff: http://sforsuresh.in/read-data-excel-sheet-insert-database-table-c/

Author: Suresh Kamrushi
Posted: August 23, 2018, 10:52 am

A simple example how you can read excel file using EPPlus in .net 4.5

public void readXLS(string FilePath)
{
    FileInfo existingFile = new FileInfo(FilePath);
    using (ExcelPackage package = new ExcelPackage(existingFile))
    {
        //get the first worksheet in the workbook
        ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
        int colCount = worksheet.Dimension.End.Column;  //get Column Count
        int rowCount = worksheet.Dimension.End.Row;     //get row count
        for (int row = 1; row <= rowCount; row++)
        {
            for (int col = 1; col <= colCount; col++)
            {
                Console.WriteLine(" Row:" + row + " column:" + col + " Value:" + worksheet.Cells[row, col].Value.ToString().Trim());
            }
        }
    }
}
Author: Suresh Kamrushi
Posted: August 22, 2018, 9:41 am

A simple example how you can use EPPlus to read excel file:

Reff : http://sforsuresh.in/reading-excel-file-using-epplus-package/

public void readXLS(string FilePath)
{
    FileInfo existingFile = new FileInfo(FilePath);
    using (ExcelPackage package = new ExcelPackage(existingFile))
    {
        //get the first worksheet in the workbook
        ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
        int colCount = worksheet.Dimension.End.Column;  //get Column Count
        int rowCount = worksheet.Dimension.End.Row;     //get row count
        for (int row = 1; row <= rowCount; row++)
        {
            for (int col = 1; col <= colCount; col++)
            {
                Console.WriteLine(" Row:" + row + " column:" + col + " Value:" + worksheet.Cells[row, col].Value.ToString().Trim());
            }
        }
    }
}
Author: Suresh Kamrushi
Posted: August 22, 2018, 9:29 am

Is there any library/class/plugin available for generating QR code and Barcode?
I am getting is two different libraries for each one of them.
It will be good if I can get in single library with both functionality.

After google I found few links like this:

https://github.com/dwisetiyadi/CodeIgniter-PHP-QR-Code
https://www.sitepoint.com/generate-qr-codes-in-php/

Author: Suresh Kamrushi
Posted: May 2, 2017, 7:39 am

I Think bitwise operator are the best way to implement user permission. Here I am showing how we can implement it with MySQL.

Below is a sample tables with some sample data:

Table 1: Permission table to store permission name along with it bit like 1, 2, 4, 8.. etc (multiple of 2)

CREATE TABLE IF NOT EXISTS `permission` (
  `bit` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`bit`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Insert some sample data into the table.

INSERT INTO `permission` (`bit`, `name`) VALUES
(1, 'User-Add'),
(2, 'User-Edit'),
(4, 'User-Delete'),
(8, 'User-View'),
(16, 'Blog-Add'),
(32, 'Blog-Edit'),
(64, 'Blog-Delete'),
(128, 'Blog-View');

Table 2: User table to store user id,name and role. Role will be calculated as sum of permissions.
Example:

If user 'Ketan' having permission of 'User-Add' (bit=1) and 'Blog-Delete' (bit-64) so role will be 65 (1+64).
If user 'Mehata' having permission of 'Blog-View' (bit=128) and 'User-Delete' (bit-4) so role will be 132 (128+4).

CREATE TABLE IF NOT EXISTS `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `role` int(11) NOT NULL,
  `created_date` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

Sample data-

INSERT INTO `user` (`id`, `name`, `role`, `created_date`)
   VALUES (NULL, 'Ketan', '65', '2013-01-09 00:00:00'),
   (NULL, 'Mehata', '132', '2013-01-09 00:00:00');

Loding permission of user After login if we want to load user permission then we can query below to get the permissions:

SELECT permission.bit,permission.name  
   FROM user LEFT JOIN permission ON user.role & permission.bit
 WHERE user.id = 1

Here user.role "&" permission.bit is a Bitwise operator which will give output as -

User-Add - 1
Blog-Delete - 64

If we want to check weather a particular user have user-edit permission or not-

  SELECT * FROM `user` 
     WHERE role & (select bit from permission where name='user-edit')

Output = No rows.

You can see also: http://sforsuresh.in/implemention-of-user-permission-with-php-mysql-bitwise-operators/

Author: Suresh Kamrushi
Posted: September 3, 2014, 12:09 pm