Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 448

Laravel insert or update multiple rows

$
0
0

Im new in laravel, and im trying to update my navigation tree.So i want to update my whole tree in one query without foreach.

array(  array('id'=>1, 'name'=>'some navigation point', 'parent'='0'),  array('id'=>2, 'name'=>'some navigation point', 'parent'='1'),  array('id'=>3, 'name'=>'some navigation point', 'parent'='1'));

I just want to ask - is there posibility in laravel to insert(if new in array) or update my current rows in database?

I want to update all, because i have fields _lft, _right, parent_id in my tree and im using some dragable js plugin to set my navigation structure - and now i want to save it.

I tried to use

Navigation::updateOrCreate(array(array('id' => '3'), array('id'=>'4')), array(array('name' => 'test11'), array('name' => 'test22')));

But it works just for single row, not multiple like i tried to do.Maybe there is another way to do it?


Viewing all articles
Browse latest Browse all 448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>