view original | go back | toggle font


Lynda Accessing Databases with Object Oriented PHP

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. Topics include:

  1. Introduction

13m 33s

1.  <dl><dt><span>Welcome</span><dd>1m 4s</dd></dt></dl>
2.  <dl><dt><span>What you should know before watching this course</span><dd>2m 8s</dd></dt></dl>
3.  <dl><dt><span>Using the exercise files</span><dd>4m 56s</dd></dt></dl>
4.  <dl><dt><span>Setting SQLite permissions</span><dd>1m 11s</dd></dt></dl>
5.  <dl><dt><span>A quick primer on using PHP objects</span><dd>4m 14s</dd></dt></dl>
  1. 1. Why Use Object-Oriented PHP to Access a Database?

10m 12s

1.  <dl><dt><span>Overview of PHP database APIs</span><dd>4m 5s</dd></dt></dl>
2.  <dl><dt><span>Using prepared statements</span><dd>4m 24s</dd></dt></dl>
3.  <dl><dt><span>Using transactions</span><dd>1m 43s</dd></dt></dl>
  1. 2. PHP Data Object (PDO) Basics

48m 57s

1.  <dl><dt><span>Creating a database source name</span><dd>2m 3s</dd></dt></dl>
2.  <dl><dt><span>Connecting to a database with PDO</span><dd>7m 27s</dd></dt></dl>
3.  <dl><dt><span>Looping directly over a SELECT query</span><dd>3m 49s</dd></dt></dl>
4.  <dl><dt><span>Fetching a result set</span><dd>8m 3s</dd></dt></dl>
5.  <dl><dt><span>Finding the number of results from a SELECT query</span><dd>7m 14s</dd></dt></dl>
6.  <dl><dt><span>Checking if a SELECT query contains results</span><dd>3m 32s</dd></dt></dl>
7.  <dl><dt><span>Executing simple non-SELECT queries</span><dd>6m 2s</dd></dt></dl>
8.  <dl><dt><span>Getting error messages</span><dd>7m 17s</dd></dt></dl>
9.  <dl><dt><span>Using the quote() method to sanitize user input</span><dd>3m 30s</dd></dt></dl>
  1. 3. PDO-Prepared Statements and Transactions

39m 51s

1.  <dl><dt><span>Binding input and output values</span><dd>2m 36s</dd></dt></dl>
2.  <dl><dt><span>Using named parameters</span><dd>9m 51s</dd></dt></dl>
3.  <dl><dt><span>Using question marks as anonymous placeholders</span><dd>2m 35s</dd></dt></dl>
4.  <dl><dt><span>Passing an array of values to the execute() method</span><dd>5m 20s</dd></dt></dl>
5.  <dl><dt><span>Binding results to variables</span><dd>7m 53s</dd></dt></dl>
6.  <dl><dt><span>Executing a transaction</span><dd>6m 54s</dd></dt></dl>
7.  <dl><dt><span>Closing the cursor before running another query</span><dd>4m 42s</dd></dt></dl>
  1. 4. Advanced PDO Fetch Methods

21m 20s

1.  <dl><dt><span>Generating an array from a pair of columns</span><dd>2m 44s</dd></dt></dl>
2.  <dl><dt><span>Setting an existing object's properties with a database result</span><dd>4m 42s</dd></dt></dl>
3.  <dl><dt><span>Creating an instance of a specific class with a database result</span><dd>6m 1s</dd></dt></dl>
4.  <dl><dt><span>Reusing a result set</span><dd>7m 53s</dd></dt></dl>
  1. 5. MySQL Improved Basics

38m 14s

1.  <dl><dt><span>Connecting to a database with MySQLi</span><dd>5m 57s</dd></dt></dl>
2.  <dl><dt><span>Setting the character set</span><dd>1m 57s</dd></dt></dl>
3.  <dl><dt><span>Submitting a SELECT query and getting the number of results</span><dd>4m 4s</dd></dt></dl>
4.  <dl><dt><span>Fetching the result</span><dd>7m 35s</dd></dt></dl>
5.  <dl><dt><span>Rewinding the result for reuse</span><dd>3m 20s</dd></dt></dl>
6.  <dl><dt><span>Handling non-SELECT queries</span><dd>5m 27s</dd></dt></dl>
7.  <dl><dt><span>Getting error messages</span><dd>5m 47s</dd></dt></dl>
8.  <dl><dt><span>Sanitizing user input with real_escape_string()</span><dd>4m 7s</dd></dt></dl>
  1. 6. MySQLi Prepared Statements and Transactions

27m 49s

1.  <dl><dt><span>Initializing and preparing a statement</span><dd>4m 17s</dd></dt></dl>
2.  <dl><dt><span>Binding parameters and executing a prepared statement</span><dd>5m 55s</dd></dt></dl>
3.  <dl><dt><span>Binding output variables</span><dd>5m 6s</dd></dt></dl>
4.  <dl><dt><span>Executing a MySQLi transaction</span><dd>7m 5s</dd></dt></dl>
5.  <dl><dt><span>Dealing with "commands out of sync" in prepared statements</span><dd>5m 26s</dd></dt></dl>
  1. 7. Diving Deeper into MySQLi

24m 7s

1.  <dl><dt><span>Buffered and unbuffered queries</span><dd>4m 19s</dd></dt></dl>
2.  <dl><dt><span>Using real_query()</span><dd>6m 1s</dd></dt></dl>
3.  <dl><dt><span>Freeing resources that are no longer needed</span><dd>2m 31s</dd></dt></dl>
4.  <dl><dt><span>Submitting multiple queries</span><dd>6m 41s</dd></dt></dl>
5.  <dl><dt><span>Creating an instance of a class from a result set</span><dd>4m 35s</dd></dt></dl>
  1. Conclusion

3m 31s

1.  <dl><dt><span>PDO and MySQLi compared</span><dd>3m 31s</dd></dt></dl></article>