I am using mssql with laravel 5.1, and I know Laravel can do this:
$num_of_updated_records = DB::update(DB::raw('UPDATE [dbo].[myTable] SET selection=1 WHERE id IN (1,2,3)'));
$updated_record_ids = DB::select(DB::raw('SELECT id FROM [dbo].[myTable] WHERE selection=1'));
But it will hit the DB 2 times.
What if I want to do this to avoid hitting the DB twice:
DECLARE @MyTableVar table(selected_id bigint NOT NULL)
UPDATE [dbo].[myTable] SET selection=1
OUTPUT inserted.id INTO @MyTableVar
WHERE id IN (1,2,3)
SELECT selected_id FROM @MyTableVar
DB::select() will just return empty array.
DB::statement() will just return true.
DB::update() will only return integer 3.
Does Laravel have a function for such query to return the data from that last select of the temp table?
Thanks.