S
S
Sergey Sokolov2014-12-18 16:52:59
MySQL
Sergey Sokolov, 2014-12-18 16:52:59

How to initialize custom mysql variable in Laravel 4?

I want to execute a query with the @total variable:

SET @total = 0;
SELECT ...
    @total := @total + x AS total_x,
    ...
WHERE
    @total < 1000

Through phpMyAdmin the request works. Problems in Laravel. Tried both in one call: DB::select( DB::raw( $query)), and in two consecutive ones:
DB::statement( DB::raw( 'SET @total := 0'));
$results = DB::select( $query); // тут только "select.."

How to be and what to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Baev, 2014-12-25
@Grivachoz

DB::unprepared() will save you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question