Laravel Classroom image

Anil  Bist / Professional / 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.10 Insert
Finally, let’s store some data. All this time we have been looking at reading data but this will
be more fun! Well it’s quite simple really. To insert a new row all we have to do is provide a
key-value array to the insert() method, which is a trigger method by the way!
1 <?php
2
3 DB::table('shoes')->insert(array(
4 'color' => 'hot pink',
5 'type' => 'heels',
6 'size' => '12'
7 ));
Wait, lets grab the id thats created with this new row, it might be handy later? We can use
insert_get_id() with the same parameters for this.
1 <?php
2
3 $id = DB::table('shoes')->insert_get_id(array(
4 'color' => 'hot pink',
5 'type' => 'heels',
6 'size' => '12'
7 ));
That’s my weekend pair, let’s keep this between us. We now have a nice hot pink pair of heels
in size 12, stored in the shoes table of our database.

 

 
 
 
image
Anil  Bist

Skills    Laravel

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)