N
N
Nikolay Alekseev2019-09-19 17:52:44
Laravel
Nikolay Alekseev, 2019-09-19 17:52:44

How to prevent Eloquent from escaping raw requests?

Good day to all!
There is a need to execute a raw request.
This is expedient due to the fact that the request is specific, it simply takes blob data from a certain table and puts it in a folder on the server in the form of a real file, but
that 's bad luck and so on, since the path to the file from such turns into such In the documentation, I did not find information anywhere on how to disable escaping. I ask for tips, where to dig?
$results = DB::select($query);
$results = DB::select(DB::raw($query));

'/var/www/html/...'
'\/var\/www\/html\/...'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Alekseev, 2019-09-20
@VariusRain

In general, I found the answer myself and its origins, as it turned out, were not at all where I was looking.
The problem was that I naively believed that since the query contains the word SELECT, then I also need to call the Select method from Eloquent.
However, the fact that this very select was made, roughly speaking, into a file and, as a result, did not return results and led to an error.
I replaced DB::select with DB::statement and everything was fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question