1 month ago

Laravel LIKE Qurey Dynamic Variable Problem

Posted 1 month ago by itrabbi24

I get some value from my database.

$auth_dept_code = Auth::user()->dept_code; $auth_branch_code = Auth::user()->branch_code; $auth_code = $auth_dept_code.$auth_branch_code ;

//auth_code is 1001


when I am search tmsid LIKE '%$auth_code%'

this variable auth_code that is not working...... but when I am declared variable is

$auth_code = 1001;

and Query is executed at that time is working... but I need a dynamic variable to search.

why dynamic variables are not working?? Please give me a solution.

$submenus =DB::select(DB::raw("SELECT tmsid, RIGHT(tmsid,6) as max_number FROM tms_tables WHERE tmsid=(SELECT MAX(tmsid) FROM tms_tables where tmsid LIKE '%$auth_code%' )"));

please give me a solution.

Please sign in or create an account to participate in this conversation.