mySQL

We now have Package Deals to create and maintain your website for you.
(includes special prices for community groups and hobby clubs)

Here is a new series of tutorials comparing the mySQLi and PDO interfaces for accessing mySQL databases.

  1. Connecting to a mySQL Database
    We begin by comparing the alternative ways we can connect to a mySQL database.
  2. Database Deletes
    The simplest of the common database calls and therefore the one that is the most similar between PDO and mySQLi.
  3. Database Updates
    The main difference between a delete and an update is that you might only have one variable to bind in a delete but you always need at least two for an update.
  4. Database Inserts
    These are the database calls that will have the largest number of variables to bind.
  5. Handling Errors as Exceptions
    We can either test for errors in each database call or we can wrap them in a try block and catch exceptions.
  6. Affected Rows
    Another way to check if your call worked the way you expected.
  7. Select (with record count)
    To be able to count the number of rows returned we need to return all the results at once.
  8. Select (without record count)
    If we don't need a row count we can return the rows one at a time.
  9. Select and Bind
    An extra and unnecessary way of retrieving the data with mySQLi.
  10. bindParam and bindValue
    PDO provides two ways to do the bind - by variable name or by the current content of the variable.
  11. Transaction Processing
    A look at the difference in how mySQLi and PDO handle transaction processing.

For those who are yet to upgrade from the mysql interface that was declared to be obsolete in 2013 and which is now no longer a part of PHP the following compare the main commands you need to convert with the quickest to convert to equivalents.

  1. mysql and mysqli - Connect
    A look at these two alternate interfaces and how to use them to connect to the database.
  2. mysql and mysqli - Query
    How these two interfaces differ in how you can use them to run database queries.

The following are more general articles about mySQL and relational databases in general.

If you have a different PHP or mySQL question please ask Felgall.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate