I have ha bunch of mathematical tasks which I want to filter through a textbox.
For example: 4*1 should return 4*1, 4*10, 4*11, ... 4*11 should return 4*11
To do that I wrote this piece of code:
$operator = DB::connection()->getPdo()->quote("{$operator}");
$operand2 = DB::connection()->getPdo()->quote("{$operand2}%");
DB::table('tasks')
->select(DB::raw('*'))
->whereRaw("operand1 = {$operand1} AND operator = {$operator} AND CAST(operand2 AS CHAR(50)) LIKE {$operand2}")
->get();
The results of this are pretty unexpected und unpredictable.
When I type 4*5 I get 4*{any operand}
When I type 4*12 I get 4*1, 4*10, 4*11, 4*12
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire