From Creation to Deletion: MySQL’s Complete Data Toolkit What are CRUD operations? Create, Read, Update, Delete. That’s what we have created over the last few articles. The last piece of the puzzle is to combine them into one file that knows how to manage our authors table. If you’re jumping straight into this article, I recommend that you read the earlier articles leading up to this one first. You don’t need to, but it’ll help. MySQL Introduction MySQL DB Connection MySQL Tables MySQL Insert MySQL Insert with Prepared Statements MySQL Insert Multiple Records with Prepared Statements MySQL Select MySQL Update (PUT vs

MySQL Prepared Statements for Bulk Data Inserts You may notice a small buildup between articles, and that’s intentional. No reason to overwhelm or dilute the topic. In this article, we’ll answer one additional question related to inserting data with prepared statements: do you need to keep binding variables for each set of data that you’re inserting? Let’s just spoil that response: you don’t. Setup the binding once, change the variables, and execute. It may look a little strange, but as long as you know the flow, it will work. Recap <?php namespace Authors; require_once(“DB.php”); use Database\DB; class Author {

MySQL’s Shielded Data Transformation There’s one big flaw in our previous MySQL insert statement: it’s open to SQL Injection Attacks. Prepared statements virtually eliminate that concern. You tell the SQL server what you’re intending to do and then you give it the data. For example, you can tell the server that you’re planning on inserting data. If you send a delete statement disguised in your insert statement, that doesn’t make sense and will not have the same kind of effect that it would without prepared statements. Recap Our Author class had an insert statement that accepted data and inserted it into the authors table. <?php namespace

Infusing Tables with Fresh Data Energy We have our database connection, our database, and our table. We just need to start adding some data to it. This is a basic functionality that you’ll need to do constantly. Each time a form is submitted, where’s that data going to go? Will it be emailed or will it be stored in a database? Let’s do this the right way: the object oriented way. Our assignment for this article will be to connect to a database and insert an author into our authors table. If you need to review how we got to this point,