11.08.2017 Views

codebright

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Eloquent ORM 261<br />

18 }<br />

19<br />

20 $book = new Book;<br />

21 $book->name = 'The Colour of Magic';<br />

22 $book->description = 'Rincewind and Twoflower in trouble!';<br />

Wonderful!<br />

We have created a book to represent Terry Pratchett’s ‘The Colour of Magic’, one of my personal<br />

favourites! Now let’s store this book in our database. We will assume that we used the schema builder<br />

and have already created a ‘books’ table with all required columns.<br />

First we will need to construct an SQL query. Now I know that you would probably build a prepared<br />

query for security reasons, but I want to keep the example simple. This should do the trick…<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!