6 days ago

Laravel Qurey Dynamic Variable Problem

Posted 6 days ago by itrabbi24

I get some value from my database.

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

//auth_code is 1001


when I am search

tmsid LIKE '%$auth_code%'

LIKE '%{$auth_code}%'

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.

please give me a solution.

Here is some screenshot

Not Working

Working type of static value

Not Working...


same problem

the dynamic variable is not working

$auth_dept_code = Auth::user()->dept_code; 		// 1
$auth_branch_code = Auth::user()->branch_code;	// 0001
$auth_code = intval($auth_dept_code.$auth_branch_code); //1001 

error_reporting( ~E_NOTICE );

$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%' )"));


@foreach($submenus as $row)
  $num = $row->max_number;
      $len = strlen($num);
          for($i=$len; $i< 6; ++$i) {
        $num = '0'.$num;

echo $auth_code; echo '-'; echo $num;

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