Laravel Classroom image

Prashant  Nigam / Student / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14|Last
Lessons:-Fluent Query Builder

10.11 Update
Wait, did I say heels in that last section? They were hot pink skate shoes! If only we could go
back and fix our mistake. I could update the table and no one would see my shame. Oh I guess
we could probably use the update() method, you see it takes an array with the same syntax as
insert().
1 <?php
2
3 DB::table('shoes')->update(array(
4 'type' => 'skate shoes'
5 ));
Hold on, we aren’t specifying a record here. I don’t want to change all my records to skate shoes,
it would ruin my wonderful Laravel flip flops. Let’s use a where() method and that $id we got
earlier to narrow it down to the record we want. Chain time!
1 <?php
2
3 DB::table('shoes')
4 ->where('id', '=', $id)
5 ->update(array(
6 'type' => 'skate shoes'
7 ));
There, we fixed the problem before anyone noticed.

 
 
 

Prashant  Nigam

Skills    Laravel

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)