Using '->where()' in PHP file to restrict filter based on SESSION USER / LOGIN

Using '->where()' in PHP file to restrict filter based on SESSION USER / LOGIN

BalaKrishnanDhanuskodiBalaKrishnanDhanuskodi Posts: 45Questions: 17Answers: 0

Happy Evening one and All,

Following is the code used to fetch specific row corresponding to specific Account Manager based on Session/Login.

 ->where( 'Accoutn_Manger', $_SESSION['SESS_FIRST_NAME'].' '.$_SESSION['SESS_LAST_NAME']).

I understood that where() can be used to force filter as the data table fetches data from MySQL. I have super admin and following is user User Level details.

Account Manager = User Level = 4
Super Admin = User Level = 1

So if Super Admin log's in the datatable should display all data i.e. without Account Manager Restriction - So tried following and found not working.

 ->where( 'Accoutn_Manger', $_SESSION['SESS_FIRST_NAME'].' '.$_SESSION['SESS_LAST_NAME'], $_SESSION['SESS_USER_LEVEL'] = 4).

Any help would be greatful.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,433Questions: 1Answers: 10,049 Site admin

    Could you write the WHERE SQL statement that you are trying to generate please, and I'll translate it into the Editor PHP libraries. I'm not clear if you need an AND or an OR statement.

    Thanks,
    Allan

  • BalaKrishnanDhanuskodiBalaKrishnanDhanuskodi Posts: 45Questions: 17Answers: 0

    Sure Allan, sorry for the confusion... Please find the SQL statement.

    SELECT * FROMtable1_dataWHERE user_level = 4 AND account_manager = "John";

  • BalaKrishnanDhanuskodiBalaKrishnanDhanuskodi Posts: 45Questions: 17Answers: 0
    edited October 2017

    -

  • allanallan Posts: 61,433Questions: 1Answers: 10,049 Site admin
    Answer ✓
    ->where( 'user_level', 4 )
    ->where( 'account_manager', 'John' );
    

    For an AND condition, call where twice.

    Allan

  • BalaKrishnanDhanuskodiBalaKrishnanDhanuskodi Posts: 45Questions: 17Answers: 0

    Thanks Allan,

This discussion has been closed.