PHP: Accessing Databases with PDO and MySQLi
Offered By: LinkedIn Learning
Course Description
Overview
Learn how to access and manipulate databases using the object-oriented PHP extensions PDO and MySQLi.
Now that PHP has true object-oriented capabilities, it's best practice to access databases using PDO (PHP Data Objects) and MySQLi. These methods produce database-neutral code that works with over a dozen systems, including MySQL, SQL Server, PostgreSQL, and SQLite. Learn how to use PDO and MySQLi to perform basic select, insert, update, and delete operations; improve security with prepared statements; and use transactions to execute multiple queries simultaneously. Author David Powers also covers advanced topics like instantiating custom objects, and compares PDO to MySQLi so you can decide which method is right for you.
Now that PHP has true object-oriented capabilities, it's best practice to access databases using PDO (PHP Data Objects) and MySQLi. These methods produce database-neutral code that works with over a dozen systems, including MySQL, SQL Server, PostgreSQL, and SQLite. Learn how to use PDO and MySQLi to perform basic select, insert, update, and delete operations; improve security with prepared statements; and use transactions to execute multiple queries simultaneously. Author David Powers also covers advanced topics like instantiating custom objects, and compares PDO to MySQLi so you can decide which method is right for you.
Syllabus
Introduction
- Welcome
- What you should know before watching this course
- Using the exercise files
- Setting SQLite permissions
- A quick primer on using PHP objects
- Overview of PHP database APIs
- Using prepared statements
- Using transactions
- Creating a database source name
- Connecting to a database with PDO
- Looping directly over a SELECT query
- Fetching a result set
- Finding the number of results from a SELECT query
- Checking if a SELECT query contains results
- Executing simple non-SELECT queries
- Getting error messages
- Using the quote() method to sanitize user input
- Binding input and output values
- Using named parameters
- Using question marks as anonymous placeholders
- Passing an array of values to the execute() method
- Binding results to variables
- Executing a transaction
- Closing the cursor before running another query
- Generating an array from a pair of columns
- Setting an existing object's properties with a database result
- Creating an instance of a specific class with a database result
- Reusing a result set
- Connecting to a database with MySQLi
- Setting the character set
- Submitting a SELECT query and getting the number of results
- Fetching the result
- Rewinding the result for reuse
- Handling non-SELECT queries
- Getting error messages
- Sanitizing user input with real_escape_string()
- Initializing and preparing a statement
- Binding parameters and executing a prepared statement
- Binding output variables
- Executing a MySQLi transaction
- Dealing with "commands out of sync" in prepared statements
- Buffered and unbuffered queries
- Using real_query()
- Freeing resources that are no longer needed
- Submitting multiple queries
- Creating an instance of a class from a result set
- PDO and MySQLi compared
Taught by
David Powers
Related Courses
Advance your Skills as a PHP Developer: Working with DataLinkedIn Learning PHP: Object-Oriented Programming with Databases
LinkedIn Learning Conviértete en un Desarrollador Web desde cero Paso a Paso
Udemy Complete Login/Registration System in PHP & MYSQL 2021
Udemy PHP for Beginners - Learn PHP OOP MySQLi CRUD
Udemy