-
Book Overview & Buying
-
Table Of Contents
concrete5 Cookbook
By :
The final facet of CRUD actions with active record is deleting entries. In this recipe, we will load a book with the ID of 1 and delete it from the database.
We will be using the same Book model and Books table from the previous the Reading from the database with active record recipe. Make sure that file is in place before beginning this recipe.
Have a look at the following steps:
Open /config/site_post.php in your code editor.
Load the model:
Loader::model('book');Create a new instance of the model:
$book = new Book();
Load the book with the ID of 1.
$book->load('id = ?', '1');Delete that book:
$book->delete(); exit;
Calling the delete function of the Model class will run the DELETE query on the database, permanently deleting the record associated with that item. Using your preferred SQL browsing tool, you can see that the record has been removed from the database.
The Creating a custom...
Change the font size
Change margin width
Change background colour