I need to execute this query using the Codeigniter query constructor:
SET @row_number:=0; SELECT Id, @row_number: =@row _number+1 as Position FROM my_table WHERE date='2015-12-26'
I can do this using the function "$ this-> db-> query" as follows:
$query = 'SET @row_number:=0;'; $this-> db-> query ($query); $query = 'SELECT Id, @row_number: =@row _number+1 as Position'; $query = $query . ' FROM my_table'; $query = $query . ' WHERE date=\'' . $data . '\''
But, my question is: is there a way to do this without a complicated record of the request, so I'm writing something like this:
$query = 'SET @row_number:=0;'; $this-> db-> query ($query);
Fabio source share