Sep 10, 2021
5
Level 1
Query with a where clause and a fraction
I have this query in my controller but it does not return anything
$global_size = Boutique::select('price')->where('size', 7/8)->first();
if I replace the size with an integer like so below, it works
$global_size = Boutique::select('price')->where('size', 7)->first();
How can i make this query work with the size in fraction? The sizes for the boutique clothes are all in fractions like 7/8, 8/9, 10/11......... How to make this work ?
$global_size = Boutique::select('price')->where('size', 7/8)->first();
Level 122
your code now says where size = -1 since 7 minus 8 is -1
if your product is stored with a size stated as 7/8 then this is a STRING and you should query ->where('size', '7/8')
Please or to participate in this conversation.