For example:
$sql="SET @runningTotal=0; SELECT @runningTotal + a.quantity as 'RunningTotal', @runningTotal := @runningTotal +a.quantity FROM ask AS a HAVING RunningTotal <=?"
This is unfortunately not working... $result = $this->db->query($sql,[$quantity])->fetchAll();
If i run query in phpmyadmin (SET @runningTotal=0; SELECT @runningTotal + a.quantity as 'RunningTotal', @runningTotal := @runningTotal +a.quantity FROM ask AS a HAVING RunningTotal <=2) it works.