-5
insira o código aqui
I have the following query in PHP:
$transferencia = $conecta->rawSelect(
'SELECT * FROM register WHERE ROUND(valor,2)="' . $json->VALORLIQUIDO . '" '
);
How I perform this same consultation using the Eloquent Laravel?
This value field is a value float
.
tried so
$transferencia = Register::where('valor',$json->VALORLIQUIDO)->get()
It does not find any results, even if it is certain that it has this record in the database, as the column has a value float the query does not locate the result. So I need to understand how to perform a query in the Laravel using eloquent to search for records in columns that have float values.
Matthew, in the case of this query above I don’t need to indicate which column ?
– Murilo
It was barely written fast and I forgot
– Mateus
Matthew Tried like this $value = 1.11; $Register = Register::Where('value', $value)->Where(round($value, 2), $value)->get(); message: "SQLSTATE[42S22]: Column not found: 1054 Unknown column '1.11' in 'Wclause' (SQL: select * from here
register
Wherevalor
= 1.11 and1
.11
= 1.11)"– Murilo
Now that I read it calmly there, had seen it wrong, then in this case you will have to use DB::raw
– Mateus
Just having a while I ride there
– Mateus
Worked 100% Matthew! excellent solution.
– Murilo
@Murilo which one did you use?
– Mateus