Stop making your life hard and use the query builder.
Oct 25, 2017
17
Level 1
How to concate and make sql query in laravel
hi, I want to concatenate two string to a where clause and then make the sql call,.
my code is like bellow,
Controller-
$sql='Stock::';
for ($x=0; $x <count($stringArray) ; $x++) {
$string=$stringArray[$x];
$value=$valueArray[$x];
$operator=$operatorArray[$x];
$sql=$sql."where('". $string .",'". $operator."',". $value ."')->";
}
$sql=$sql."get()";
And the $stringArray,$valueArray,$operatorArray are the array values, when i dump the sql im getting the string , the concatinated values of for loop,
"Stock::where('INSTRUMENT,'=',FUTIDX')->where('CLOSE,'=',24237.55')->get()"
please Tell me how can i overcome this problem?
Please or to participate in this conversation.