Enter your Sign on user name and password.

Forgot password?
Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!

Use Chrome browser to play professor video
Matthew M.

Matthew M.

Web Application Development

Slide Duration:

Table of Contents

I. Advanced PHP with MySQL
Course Introduction

13m 36s

Intro
0:00
Advanced PHP w/ MySQL
0:13
Course Introduction
0:14
Course Content
0:59
Web Application: Educator Store
1:45
Web Application: Educator Store
1:46
Object-Oriented Programming
6:09
Object-Oriented Programming Overview
6:10
MySQL
6:50
MySQL Overview
6:51
Example: Command Prompt & MySQL
8:34
What You Will Learn
9:34
What You Will Learn
9:35
Course Prerequisites
11:52
Course Prerequisites
11:53
Advanced Course Development Environment

18m 46s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Development Environment Setup
1:36
Firefox Web Browser, XAMPP, and PSPad Text Editor
1:37
Course Directory Structure
4:36
Course Directory Structure
4:37
phpDocumentor
7:23
phpDocumentor Overview
7:24
Parsing Source Code
7:44
docs Subdirectory
9:06
Asvanced PHP Course Documentation Example
10:21
Previous Educator PHP Students
14:14
Lib Directory Changes
14:38
Images Directory Changes
14:57
VERSION Constant
15:40
Comments Noting a Specific Version Number
17:04
Homework Challenge
17:30
Homework Challenge
17:31
Introduction to File I/O

35m 37s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
File I/O
1:34
File I/O Overview
1:35
Performing file I/O: 3 Steps
1:52
File Permissions
2:28
Read Permission & Write Permission
2:29
fopen()
4:47
fopen()
4:48
Two Required Parameters
5:01
Successful fopen(): File Handle and Resource
5:21
FALSE and E_WARNING Error
6:00
Example
6:39
File Paths
7:10
File Paths
7:11
File Access Modes
9:18
File Access Modes
9:19
Coding Example: fopen()
10:31
Using Relative and Absolute Path & Non-Existent File
10:32
File Pointers
15:55
File Pointers
15:56
Example File
16:11
Opening a File with fopen() Using 'r' as the Access Mode
16:22
fgets()
17:55
fgets() Overview
17:56
Coding Example: fgets() - Reading a Line at a Time
18:26
feof()
20:10
feof() Overview
20:09
Coding Example: feof()
20:50
fclose()
23:43
fclose() Overview
23:44
Coding Example: fclose()
25:02
Coding Example: Current Stock
26:10
Coding Example: Current Stock
26:11
trim ()
31:39
trim () Overview and Example
31:40
Homework Challenge
33:35
Homework Challenge
33:36
Web Application Development

36m 36s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
Version 1.0 Changelog
0:31
catalog.php
0:32
Function Library: fileLIB.php
5:00
Version 1.1 Changelog
27:12
createItemDataArray() and createDeptDataArray()
27:13
outputSimpleItemLink() and outputSimpleDeptLink()
32:06
HTTP & the POST Method

34m 36s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
HTTP Model
1:28
HTTP Model
1:29
Client-Server Model 2 Steps Process
2:00
HTTP Messages
2:23
HTTP Messages
2:24
HTTP Requests
3:09
HTTP Requests
3:10
Example: HTTP Request Header
3:17
Coding Example: HTTP Requests
4:29
HTTP Responses
7:15
HTTP Responses
7:16
Example: HTTP Response (Header & Body)
8:00
header()
11:47
header() Overview
11:48
Coding Example: header
14:02
Coding Example: header() Error
14:52
GET Method
18:55
GET Method
18:56
Coding Example: GET Method
20:13
POST Method
21:09
POST Method
21:10
Coding Example: Sample Form Using the POST Method
23:50
Accessing POST Data in PHP
26:38
Accessing POST Data in PHP
26:39
Coding Example: Accessing POST Data via $_POST
28:15
GET vs. POST
29:54
GET vs. POST
29:55
Example: Accessing POST Data via $_POST
31:20
Example: Accessing POST Data via $_POST
31:21
Homework Challenge
33:00
Homework Challenge
33:01
Web Application Development

14m 11s

Intro
0:00
Version 2.0 Changelog
0:09
Updating the Site's Current Form to Use the POST Method
0:10
Creating Admin Website
2:55
Dynamically Generated Department List
12:40
Writing to Files

17m 38s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Review of File I/O
0:40
Review of File I/O
0:41
fwrite()
1:38
fwrite()
1:39
fputs()
2:20
'r+'
2:31
Coding Example: fwrite()
2:59
fopen() Access Modes
8:41
'a' and 'a+'
8:42
'w' and 'w+'
11:34
Homework Challenge
14:47
Homework Challenge
14:48
Web Application Development

28m 14s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
Updated Open File Functions
0:19
openItemsDataFile ( ), openDeptsDataFile ( ), and openLastAddedFile ( )
0:20
insertItem()
6:25
insertItem() Overview
6:26
Functions: createItemDataString ( ) and updateLastItemAdded ( )
7:07
addItemToDepartment ()
16:03
addItemToDepartment () Overview
16:04
Functions: createDeptDataString ( ) and updateDepartment ( )
17:55
HTTP POST: File Uploads

22m 51s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
POST Data Encoding
1:13
POST Data Encoding
1:14
When Data is Included in the Body of the HTTP POST Request and is of the Content Type
1:31
When Uploading Files Using HTTP POST
3:17
Uploading Files
6:22
Uploading Files
6:23
If Encoding Type is Not Set to Multipart/Formdata
9:27
$_FILES Superglobal
10:59
$_FILES Superglobal
11:00
Structure of $_FILES
12:15
Structure of $_FILES: Name, Type, tmp_name, Error, and Size
12:16
Coding Example: $_FILES Superglobal
13:34
Moving an Uploaded File
15:39
Introduction to Moving an Uploaded File
15:40
move_uploaded_file ( ): Definition and Example
16:40
Homework Challenge
21:19
Homework Challenge
21:20
Web Application Development

15m 30s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Uploading Item Image File
1:22
Uploading Item Image File
1:23
Uploading Item Image File (cont.)
2:43
Altering insertItem ( )
2:44
Helpfer Functions: getFileExtension ( ) and moveUploadedFile ( )
4:30
isValidItem ( )
13:03
Introduction to Object-Oriented Programming

32m 44s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Object-Oriented Programming
0:56
Introduction to Object-Oriented Programming
0:57
Associative Arrays
5:27
Associative Arrays
5:28
Classes
7:27
Classes Overview
7:28
Defining Classes
8:24
Defining Classes
8:25
Declaring Class Properties
9:25
Coding Example: Classes
10:11
Objects
12:18
Objects Overview
12:19
Classes vs. Objects
12:49
Classes vs. Objects
12:50
Instantiating Classes
14:58
Instantiating Classes
14:59
Coding Example: Instantiate an Item Object
16:30
Object Properties
19:21
Access and Set an Object's Property
19:22
Coding Example: Set & Access the Properties of an Item Object
24:23
Homework Challenge
30:22
Homework Challenge
30:23
Web Application Development

17m 47s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 5.0 Overview
0:50
Version 5.0 Overview and Examples
0:51
Outputting Object Properties
12:38
Outputting Object Properties
12:39
Array Object Properties
14:18
Access and Set Array Value
14:19
Object Methods

39m 57s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Object Methods
0:52
Definition of Object Methods
0:53
Calling Object Methods
3:25
Calling Object Methods
3:26
Coding Example: Simple Object Methods
4:44
Object Methods and Return Values
7:02
$this Variable
10:06
$this Variable: Definition and Example
10:07
$this Variable (cont.)
15:51
$this Variable (cont.)
15:52
Getters & Setters
21:21
Getters & Setters Methods
21:22
Object Methods In Strings
25:46
Object Methods In Strings
25:47
Coding Example: Outputting Method Return Values in Strings
27:41
Using $this to Call Other Methods
28:49
Using $this to Call Other Methods
28:50
Homework Challenge
34:18
Homework Challenge: 1-3
34:19
Homework Challenge (cont.)
36:20
Homework Challenge: 4-6
36:21
Homework Challenge (cont.)
37:52
Homework Challenge: 7-10
37:53
Web Application Development

17m 30s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 6.0 Overview
0:40
Version 6.0 Changes & Examples
0:41
Item Methods
0:53
Item Class Definition: getImageFilename()
0:54
Coding Example: getImageFilename()
1:58
Department Methods
7:33
addItem(), removeItem(), and isItemInDept() Method
7:34
addItemtToDepartment() & buildDeptObject() Functions
11:46
A Default Value Needed to Be Set for $items
16:26
Object Constructors

22m 20s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Object Constructors
0:32
Introduction to Object Constructors
0:33
Coding Example: Object Constructors
1:43
Defining Constructors
3:26
Defining Constructors
3:27
Coding Example: Constructors with No Arguments
4:24
Constructor Arguments
8:09
Constructor Arguments
8:10
Coding Example: Constructor Arguments
9:49
Important Notes
16:13
Important Notes
16:14
Homework Challenge
17:35
Homework Challenge: 1 - 4
17:36
Homework Challenge (cont.)
19:13
Homework Challenge: 5 - 9
19:14
Homework Challenge (cont.)
21:40
Homework Challenge: 10 and 11
21:41
Web Application Development

16m 19s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 7.0 Overview
0:39
Version 7.0 Overview
0:40
Item Constructor
2:19
Item Constructor
2:20
Department Constructor
7:47
Department Constructor
7:48
Customer Constructor
12:23
Customer Constructor
12:24
More Magic Methods

53m 37s

Intro
0:00
Lesson Overview
0:13
Lesson Overview
0:14
Magic Methods
1:12
Magic Methods
1:13
Destructors
2:45
Destructors Overview
2:46
Coding Example: Calling Destructors
4:30
Coding Example: Object Destructor
9:19
_to String ()
16:12
_to String () Overview
16:13
Coding Example: _to String () Magic Method
18:10
Access Modifiers
21:23
Introduction to Access Modifiers
21:24
Access Modifiers: Public
21:39
Access Modifiers: Private
22:18
Access Modifiers: Protected
22:41
Object Properties and Methods
23:06
Coding Example: Public Access Modifiers
26:48
Coding Example: Private Access Modifiers
28:30
_get()
31:37
_get() Overview
31:38
Coding Example: _get () Magic Method
33:30
_set ()
36:23
_set () & the Magic Method
36:24
Using Getters & Setters
44:37
Coding Example: Using Getters & Setters
44:38
Homework Challenge
50:33
Homework Challenge: 1 - 6
50:34
Homework Challenge (cont.)
51:41
Homework Challenge: 7 - 12
51:42
Web Application Development

31m 12s

Intro
0:00
Version 8.0 Review
0:12
Version 8.0 Review
0:13
private Object Properties
1:15
private Object Properties
1:16
Coding Example
2:54
_toString() Methods
6:51
_toString() Methods
6:52
Coding Example
8:09
DataFile Class
13:27
DataFile Class & I/O Operations
13:28
Using DataFile Class: Instantiate a DataFile, DataFile open () Method, and DataFile close () Method
18:09
Homework Challenge
29:35
Homework Challenge
29:36
Classes vs. Objects

37m 49s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Class vs. Object Review
0:58
Class vs. Object Review
0:59
Static Properties
2:42
Static Properties
2:43
Scope Resolution Operator (::)
5:26
Scope Resolution Operator (::) & Static Property
5:27
Coding Example: Accessing a Static Property Using the Scope Resolution Operator
7:57
Coding Example: Accessing a Static Property in a Class Definition
10:33
Coding Example: Using a Static Property as an Instance Counter
14:18
Static Methods
18:51
Static Methods Overview
18:52
Coding Example: Static Methods
21:39
Classes vs. Objects
26:28
Classes vs. Objects: Diagrams
26:29
Class Constants
30:24
Class Constants Definition
30:25
Coding Example: Using Class Constants
31:55
Homework Challenge
34:01
Homework Challenge: 1 - 5
34:02
Homework Challenge (cont.)
35:25
Homework Challenge: 6 - 10
35:26
Web Application Development

21m 7s

Intro
0:00
Version 9.0 Overview
0:12
Version 9.0 Changes & Examples
0:13
Output Class
1:08
Output Class & Static Methods
1:09
outputHtmlSelector ( ) Method
2:43
outputItemSelector ( ) Method
4:53
outputDeptSelector ( ) Method
6:42
buildObject() Methods
11:54
buildObject() Methods & Examples
11:55
Exceptions

22m 43s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
try Blocks
0:44
try Blocks Definition
0:45
catch Blocks
2:03
catch Blocks: Definition and Syntax
2:04
Coding Example: try/catch Blocks
3:48
When an Exception Object is Caught & Error Handling
5:59
Exception Class
7:02
Exception Class
7:03
Coding Example: Using try/catch to Catch an Exception Thrown from a Method
8:04
Re-Throwing Exceptions
16:39
Re-Throwing Exceptions
16:40
Coding Example: Re-throwing an Exception
17:21
Homework Challenge
20:40
Homework Challenge: 1 - 5
20:41
Homework Challenge (cont.)
22:17
Homework Challenge: 6
22:18
Web Application Development

22m

Intro
0:00
Version 10.0 Overview
0:11
Updating addItem.php, addItemToDept.php, and error.php
0:12
Updating DataFile Class: open ( ) Method & try/catch blocks
7:45
Version 10.1 Overview
13:37
Version 10.1 Changes & Examples
13:38
Updating DataFile Class: close ( ) Method & logWarning ( )
20:17
Cookies

39m 47s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
What is a Cookie?
1:15
Definition of Cookie
1:16
HTTP - A Stateless Protocol
2:17
HTTP - A Stateless Protocol
2:18
Purpose of Cookies
4:10
Set - Cookie Header
6:21
Introduction to Set - Cookie Header
6:22
Coding Example: Set - Cookie Header
7:38
Cookie Header
9:45
Introduction to Cookie Header
9:46
Example: Cookie Header
10:27
setcookie()
12:33
Introduction to setcookie()
12:34
Example: Using setcookie
13:54
Cookies Attributes
15:48
Cookies Attributes Overview
15:49
Common Cookies Attributes: Domain
16:24
Common Cookies Attributes: Path
17:04
Common Cookies Attributes: Expires
19:34
Coding Example: Setting Cookie Attributes
20:58
$_COOKIE Superglobal
27:03
$_COOKIE Superglobal
27:04
Coding Example: Accessing Cookies from PHP Using $_COOKIE
29:45
Security Implications
34:44
Security Implications
34:45
Homework Challenge
36:10
Homework Challenge: 1 - 4
36:11
Homework Challenge (cont.)
37:47
Homework Challenge: 5 - 7
37:48
Web Application Development

39m 11s

Intro
0:00
Lesson Overview
0:17
Lesson Overview
0:18
instanceof Operator
1:34
instanceof Operator
1:35
Objects with Object Properties
2:53
Objects with Object Properties
2:54
Version 11.0 Overview
6:41
Version 11.0 Changes: Cart and CartItem Classes
6:42
Version 11.0 Coding Example
10:40
Version 11.1 Overview
31:03
Version 11.1 Changes & Examples
31:04
Introduction to Sessions

46m 8s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
What is a Session?
0:53
What is a Session?
0:54
Client-Side Sessions
3:51
Client-Side Sessions
3:52
Server-Side Sessions
5:04
Server-Side Sessions
5:05
Session IDs
6:26
Session IDs
6:27
The SID is Used by the Server to:
7:08
A Client Passes an SID to the Server with Each HTTP Request Via:
8:15
Sessions in PHP
12:19
Sessions in PHP
12:20
session_start()
14:40
session_start() Overview
14:41
Coding Example: Using session_start () to Continue a Session
18:03
$_SESSION Superglobal
22:06
$_SESSION Superglobal Overview
22:07
Coding Example: Setting a Session Variable via $_SESSION
25:22
Accessing Session Data
28:08
Accessing Session Data
28:09
Deleting Session Data
31:43
Deleting Session Data
31:44
Coding Example: Deleting Session Data
32:16
Configuring PHP Sessions
36:14
session.cookie_lifetime, session.cookie_domain, and session.cookie_path
36:15
Coding Example: Configuring PHP Sessions
37:28
Configuring PHP Sessions (cont.)
40:56
session.use_cookies, session.use_trans_sid, and session.use_only_cookies
40:57
Coding Example: Configuring PHP Sessions
42:25
Homework Challenge
42:55
Homework Challenge: 1 - 5
42:56
Homework Challenge (cont.)
44:10
Homework Challenge: 6 - 10
44:11
Homework Challenge (cont.)
45:27
Homework Challenge: 11 - 13
45:28
Web Application Development

11m

Intro
0:00
Version 12.0 Overview
0:12
Version 12.0 Changes Part I: Updating 'viewCart.php' & 'checkout.php'
0:13
Version 12.0 Changes Part II
5:03
Destroying Sessions

29m 59s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Destroying Sessions
1:02
Destroying Sessions
1:03
session_destroy()
2:10
session_destroy() Overview
2:11
Coding Example: Setting a Session Variable and Destroying a Session
3:18
Deleting Session Cookies
8:38
Deleting Session Cookies
8:39
Coding example: Deleting Session Cookies
9:17
Review of Steps
21:07
Review of Steps
21:08
Garbage Collection
21:50
Garbage Collection Overview
21:51
Coding Example: Garbage Collection
24:30
Homework Challenge
26:28
Homework Challenge: 1 - 4
26:29
Homework Challenge (cont.)
28:16
Homework Challenge: 5 - 9
28:17
Web Application Development

19m 14s

Intro
0:00
Lesson Overview
0:13
Lesson Overview
0:14
_autoload()
0:46
Introduction to _autoload ()
0:47
Version 13.0 Overview
4:06
_autoload () and SessionManager Class
4:07
Updating 'viewCart.php' & 'checkout.php'
11:16
Introduction to Databases

21m 24s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
Flat Files
1:09
Flat Files: Definition and Example
1:10
Problems Associated with Using Flat Files as a Database
2:15
Relational Databases
3:29
Relational Databases
3:30
Relational Database Management System (RDBMS)
3:50
Tables
7:43
Tables
7:44
Columns
9:24
Columns
9:25
What is SQL?
10:45
Introduction to Structured Query Language
10:46
Standard Data Types of SQL
12:23
Primary Keys
13:19
Primary Keys
13:20
Primary Key Examples
16:36
Primary Key Examples
16:37
Introduction to MySQL

28m 11s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
What is MySQL?
1:33
MySQL
1:34
MySQL Monitor
5:16
MySQL Monitor Overview
5:17
XAMPP & MySQL
5:58
In the MySQL Command: hostname, username and -p
7:05
Connecting to a MySQl Server
9:52
Connecting to a MySQl Server
9:53
Using MySQl Monitor
13:48
Using MySQl Monitor
13:49
GRANT Command
15:10
GRANT SQL Command
15:11
Privileges & Objects
18:18
Username, Hostname, and Password
19:37
Specifying Objects
20:05
Creating a PHP User Account
21:41
Creating a PHP User Account Overview
21:42
Meaning of all & *.*
23:35
Example: Creating a PHP User Account
23:48
Required Homework
26:27
Required Homework: 1 - 5
26:28
Required Homework (cont.)
27:28
Required Homework: 6
27:29
Creating Databases & Tables

23m 1s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
Creating a Database
1:40
Introduction to Creating a Database
1:41
Example: Creating a Database
3:33
CREATE TABLE Command
6:43
CREATE TABLE Command
6:44
Data Types
7:39
Numeric Data Types: INT, INT UNSIGNED, and DECIMAL
7:40
String Data Types: CHAR (M), VARCHAR (M), and TEXT
9:23
Colum Attributes
11:00
PRIMARY KEY Attribute
11:01
AUTO INCREMENT Attribute
11:35
Items Table
13:07
Items Table
13:08
Useful Commands
17:04
SHOW TABLES Command & DESCRIBE Utility Statement
17:05
Example: Creating an Items Table
17:58
Required Homework
20:51
Required Homework: 1 - 6
20:52
Required Homework (cont.)
21:55
Required Homework: 7 - 9
21:56
SQL Command: INSERT

27m 11s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
INSERT Command
1:20
SQL INSERT Command
1:21
Specifying Values
3:16
Columns with Numeric Data Types
3:17
Columns with String Data Types
3:34
Columns with AUTO INCREMENT
4:07
Inserting Items
5:21
Inserting Items
5:22
Example: Inserting Items
7:03
SQL Text Files
14:04
SQL Monitor Client
14:05
MySQL Monitor & the < Operator
15:15
Example
17:35
Required Homework
22:32
Required Homework: 1 - 6
22:33
Required Homework (cont.)
24:19
Required Homework: 7 - 10
24:20
SQL Command: SELECT

24m 57s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
SELECT Command
0:42
SELECT Command: Definition and Syntax
0:43
Results of a SELECT Query
1:53
To Specify the Retrieval of All Columns from a Table
3:06
Example: SELECT Command
4:18
WHERE Clause
7:11
WHERE Clause
7:12
A SELECT Query with WHERE Clause has the Following Syntax
8:10
A Where Condition can Contain both Logical and Comparison Operators
9:44
Literal Values
13:24
Literal Values
13:25
Example: Literal Values
14:18
ORDER BY Clause
15:31
ORDER BY Clause & SELECT Query
15:32
Ascending and Descending Order
17:30
An ORDER BY Clause can Specify Multiple Columns to Order the Rows by
18:01
Example: SELECT Query with WHERE and ORDER BY Clause
20:32
Homework Challenge
21:59
Homework Challenge
22:00
Homework Challenge (cont.)
23:54
Homework Challenge
23:55
Using PHP from MySQL

32m 43s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
PHP/MySQL Architecture
0:56
PHP/MySQL Architecture
0:57
MySQLi Extension
3:05
MySQLi Extension
3:06
Steps to Using MySQL from PHP
5:53
Four Steps to Using MySQL from PHP
5:54
Step # 3
7:18
Connecting to a Database
8:12
To Connect to a MySQL Database
8:13
To Test for Connection Errors
10:20
Running an SQL Statement
11:54
Running an SQL Statement
11:55
Example
13:30
Processing the Results
15:58
For non-SELECT Queries
15:59
MySQLi Object Property: affected_rows
16:19
For INSERT Statements on Tables with an AUTO_INCREMENT Column
18:07
Closing the Connection
19:45
Closing the Connection
19:46
Coding Example
21:24
Coding Example: Using MySQL from PHP
21:25
Homework Challenge
29:00
Homework Challenge: 1 - 4
29:01
Homework Challenge (cont.)
31:10
Homework Challenge: 5 - 9
31:11
Web Application Development

30m 30s

Intro
0:00
Lesson Overview
0:14
Lesson Overview
0:15
sprintf()
1:28
sprintf() Overview
1:29
Example
1:56
INSERT Statements with sprintf()
5:15
INSERT Statements with sprintf()
5:16
Version 14.0 Overview
10:00
Version 14.0 Changes & Examples Part 1
10:01
Version 14.0 Changes & Examples Part 2
21:58
SELECT QUERIES from PHP

24m 22s

Intro
0:00
Lesson Overview
0:14
Lesson Overview
0:15
SELECT Queries
1:21
SELECT Queries
1:22
MySQLi_Result Class
3:17
MySQLi_Result Class: num_rows
3:18
MySQLi_Result Class: fetch_assoc ( ) and fetch_object ( )
3:59
fetch_assoc()
5:17
fetch_assoc() Overview
5:18
Coding Example: Using fetch_assoc()
9:00
stdClass Objects
12:46
stdClass Objects
12:47
fetch_object()
14:19
fetch_object() Overview
14:20
Coding Example: Using fetch_object()
16:45
Freeing Result Set Memory
18:42
Freeing Result Set Memory
18:43
Coding Example: Using free ( )
20:01
Homework Challenge
22:07
Homework Challenge: 1 - 5
22:08
Web Application Development

17m 6s

Intro
0:00
Version 15.0 Overview
0:13
Version 15.0 Changes & Examples Part 1
0:14
Version 15.0 Changes & Examples Part 2
8:43
Linking Tables

24m 32s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
A Departments Table
1:08
Departments Table
1:09
How Could We Model This in a Table: Option 1
1:26
How Could We Model This in a Table: Option 2
3:12
Database Normalization
4:37
Database Normalization
4:38
Foreign Keys
8:47
Foreign Keys
8:48
Linking Table
11:26
Linking Table
11:27
Multiple Column Primary Keys
15:30
Multiple Column Primary Keys
15:31
Example
18:51
Required Homework
22:34
Required Homework: 1 - 3
22:35
Required Homework (cont.)
24:10
Required Homework: 4
24:11
Web Application Development

24m

Intro
0:00
Version 16.0 Overview
0:11
Version 16.0 Changes
0:12
Version 16.0 Coding Examples
4:12
Version 16.0 (cont.)
18:30
Version 16.0 Changes & Examples Part 2
18:31
SQL Command: DELETE

10m 33s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
DELETE Statement
0:30
DELETE Statement & Its WHERE Clause
0:31
Delete All Rows From a Table
2:57
Using DELETE from PHP
4:04
Using DELETE from PHP Overview
4:05
Coding Example: Using DELETE from PHP
6:37
Homework Challenge
8:53
Homework Challenge: 1 - 4
8:54
Web Application Development

16m 2s

Intro
0:00
Version 17.0 Overview
0:11
Version 17.0 Changes
0:12
Version 17.0 Coding Example
2:51
Transactions
12:50
Database Transaction
12:51
Steps in Using Transactions
14:00
SQL Command: UPDATE

32m 14s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
UPDATE Statement
0:54
UPDATE Statement & Its WHERE Clause
0:55
Example: UPDATE Statement
3:32
Using UPDATE from PHP
5:21
Using UPDATE from PHP Overview
5:22
Coding Example: Using UPDATE from PHP
6:53
htmlspecialchars()
9:04
htmlspecialchars()
9:05
Encoding Special Characters
9:23
Coding Example: htmlspecialchars()
13:41
addslashes()
20:40
addslashes()
20:41
Coding Example: addslashes()
22:52
Homework Challenge
27:55
Homework Challenge: 1 - 2
27:56
Homework Challenge (cont.)
30:14
Homework Challenge: 3 - 5
30:15
Homework Challenge (cont.)
30:41
Homework Challenge: 6 - 9
30:42
Web Application Development

12m 33s

Intro
0:00
Version 18.0 Overview
0:12
Version 18.0 Changes
0:13
Version 18.0 Coding Example
1:24
SQL: Joins

42m 16s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
DATETIME Data Type
1:52
DATETIME Data Type
1:53
Modeling Orders
5:12
Modeling Orders
5:13
Customers Table
10:46
Customers Table
10:47
Example
16:18
Example: Order Table in MySQL
16:19
Joins
22:26
Joins Overview
22:27
Inner Join
23:09
Example: Joins
24:11
Join Conditions
28:14
Join Conditions
28:15
Example
28:32
Join Queries
30:00
Example: Join Conditions in MySQL
30:36
Implicit Joins
34:42
Implicit Joins
34:43
Example: Implicit Joins
35:57
Aliases
37:28
Introduction to Aliases
37:29
Example: Aliases
38:55
Required Homework
40:32
Problem 1
40:33
Problem 2
41:01
Problem 3
41:17
Web Application Development

29m 34s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Inserting Orders
0:44
Inserting Orders
0:45
Version 19.0 Overview
3:45
Version 19.0 Changes & Example Part 1
3:46
Version 19.0 Changes & Example Part 2
13:18
Version 19.1 Overview
21:10
Version 19.1 Changes
21:11
Version 19.1 Coding Example
22:18
User Authentication

26m 13s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
User Authentication
1:31
User Authentication
1:32
Authentication with Sessions
2:34
Authentication with Sessions
2:35
Four Steps in Authentication via Sessions
2:50
Using Sessions to Restrict Access
3:58
Using Sessions to Restrict Access
3:59
Coding Example: Restricted Access Area
4:47
Authentication Methods
5:54
Authentication Methods Overview
5:55
Coding Example: Authentication Methods
7:31
Logging Out
9:57
Logging Out
9:58
Coding Example: Log Out
10:47
Users Table
13:50
Users Table
13:51
Example: Creating a Users Table
15:08
Password Hashing
17:30
Password Hashing
17:31
PHP and MySQL Built-in Hash Functions: sha1 ( ) and md5 ( )
18:43
Coding Example: Password Hashing
19:27
Required Homework
24:41
Required Homework: 1 - 4
24:42
Web Application Development

14m 36s

Intro
0:00
Version 20.0 Overview
0:13
Version 20.0 Changes & Examples Part 1
0:14
Version 20.0 Changes & Examples Part 2
5:05
Version 20.0 Changes & Examples Part 3
7:29
Version 20.0 (cont.)
8:31
Version 20.0 Changes & Examples Part 4
8:32
Loading...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Advanced PHP
  • Discussion

  • Download Lecture Slides

  • Table of Contents

  • Transcription

  • Related Services

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Sign up for Educator.com

Membership Overview

  • Unlimited access to our entire library of courses.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lesson files for programming and software training practice.
  • Track your course viewing progress.
  • Download lecture slides for taking notes.
  • Learn at your own pace... anytime, anywhere!

Web Application Development

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Version 16.0 Overview 0:11
    • Version 16.0 Changes
    • Version 16.0 Coding Examples
  • Version 16.0 (cont.) 18:30
    • Version 16.0 Changes & Examples Part 2

Transcription: Web Application Development

Hello again, and welcome back to Educator.com's Advanced PHP with MySQL course.0000

In today's lesson, we are going to be continuing development of our web application,0005

incorporating what we learned in our last lesson about linking tables.0008

What we learned in our last lesson was how to set up our database so that it can handle departments.0014

And what we have done is created two tables in our database: a Departments table, and a depts_items table,0020

to store all of the information about a department.0027

And the depts_items table is our linking table, and that is what we use to keep entries associating items with a particular department.0029

What we are going to be doing today in our version 16.0 of the web application is:0041

we are going to be officially moving all of our web application functionality that deals with departments0046

out of this departments.txt file and the functions that operate on that, that were in fileLIB.php,0051

and moving everything into the MySQL database.0057

And how we are going to do that is: we are going to be implementing some more methods in our DatabaseAccess class0061

that are going to allow us to add items to our store, add items to a department in the store,0068

and then also to be able to retrieve department information from the store.0074

For example, we know two types of SQL statements so far.0079

We know about INSERT statements, as the first one; so we are going to learn how to insert a department into the store, using an INSERT statement.0084

Then, as a separate operation, we are going to learn how to add an item to a department.0090

What is going to happen is: in our INSERT Department functionality, we are just going to be inserting a row into the Departments table.0096

And as we saw in our last lesson, the Departments table just has the department ID and the name of the department.0109

And then, all of the items in the store are contained in the depts_items table.0116

So, this method here, addItemToDepartment, is going to be inserting a row into the depts_items table.0120

What that is going to allow us to do is to associate a particular itemID with a particular deptID, essentially adding that item to the department.0131

Between these two types of INSERT statements we are going to have, we are going to be able to add a department and add items to it.0139

Now, what that means is that the information for a department is going to be spread across two different tables.0146

In our second type of query that we know about, our SELECT query, we are going to have a couple of methods0152

that are going to have to make use of that knowledge that the department information is spread over two tables.0157

For example, we are going to have a getDepartment method, which is going to have to run two queries to load a Department object.0163

It is going to have to run a query on the Departments table to be able to load the name and department ID of a particular department.0170

And then, it is also going to have to run a query on depts_items table to be able to load all of the item ID's of the items in that particular department.0177

getDepartments is going to work in the same way, except it is going to create Department objects for all of the departments in array.0186

So, it is going to be running multiple sets of SELECT queries.0192

isItemInDepartment is a method we are going to be using that is a query we are going to run on the depts_items table.0196

And what it is going to allow us to do is to see whether an item is in a particular department.0206

We will be providing this method a deptID and an itemID, which are rows in our depts_items table.0212

And it is just going to check to see if a pair like this exists in that table.0226

And if it does, that means that the item is in the department.0230

We are also, like for our Item object that we have in our department in the store...we are going to create a deptExists function,0232

which is going to run a SELECT query; in this particular case, it is just going to run it on the Departments table.0240

And it is just going to check to see if a department with a particular department ID exists in our store.0245

Let's take a look at the DatabaseAccess class and the updates that we have made to that,0252

in order to see these new functions that we talked about.0258

I'll blow this up a little bit.0261

First of all, in our last version of DatabaseAccess, besides the constructor and destructor, we had four other public methods.0264

We had a getItem and getItems method, which were used to retrieve an item from the database; they called a single SELECT query on the Items table.0273

And that is because all of the information about an item is stored in that single table,0284

whereas for our departments, it is stored across two tables.0287

We have the insertItem method, which performs an INSERT query on our Items table,0291

and then itemExists is the method that would test if an item exists in our database, simply by searching0296

to see if a row exists with a particular item ID in the Items table.0303

In our new version of DatabaseAccess, we have a number of additional methods.0308

We have two 'get' methods, as we had just mentioned on the slides.0313

We have a getDepartment method and a getDepartments method that are going to load,0317

respectively, a single department from the database, or an array of all of the departments in the database.0321

And the way that they are going to do that is: they are both going to have to run two SELECT queries per department.0327

You are going to have to run, as mentioned, one SELECT query on the Departments table to get the name and the ID of the table,0331

and then another on the depts_items linking table to be able to build up an array0336

of all of the item ID's that are contained in a particular department.0342

Those are the analogs of getItem and getItems.0346

In the same way, we have an insertDepartment function, which is an analog for the insertItem function.0350

We have deptExists, which is just like itemExists.0357

We have isItemInDepartment, which, as we just mentioned, is something that doesn't really have an analog for an item.0361

But it, as mentioned, just tests if an item is in a department.0368

And then, we have also added this addItemToDepartment method, which is going to create a pair in that linking table0371

that is going to link an item to a particular department.0377

First, let's look at the insertDept method.0381

And what this does is takes a Department object, and then it is going to extract the information from that Department object,0387

create an INSERT query, and insert a row into the Departments table.0395

The only thing that is really in our Departments table...and actually, if I load up the MySQL Monitor,0399

and I describe our Departments table, we can see that it has two columns; it has a name column and a deptID.0415

So, when we are inserting a row or department into this Departments table, we are going to be just providing it a name,0426

because it is going to auto-generate this deptID, because it is an AUTO_INCREMENT column.0433

When we call this insertDepartment function, we pass it a department object.0438

What it is going to do is build up an INSERT query that is going to insert into Departments.0442

It is going to provide null for our deptID, and that is because the table generates that0447

automatically whenever you provide a null or a 0 value for an AUTO_INCREMENT column.0452

And then, we are also going to provide the name of the department that was provided as part of the Department object supplied to this method.0457

Just as we did for inserting an item, we logged the query; we run the query.0465

We are able to get the number of rows that were affected, which, for a successful insert, in this particular case, is going to be 1.0470

And then, we also are able to extract, using the insert_id property of that MySQLi object class--0476

we are able to get the insert_id of the department that was inserted.0484

As long as one row is returned, and the insert_id was generated (meaning it wasn't equal to 0), we are not going to output an error message.0489

And instead, we are going to update that Department object, providing it that new insert_id that was generated for it.0497

So now, we have our Department object that is going to have a name and its ID.0504

And then, we return the Department object to the calling script.0509

That is how we add a row to the Departments table.0513

Now, if we want to add items to a particular department, we have a script that we have been using in the past, called addItemToDept.php,0519

where you have a dropdown box where you can select an item and a department, and you can put the two together.0526

Well, now we have a method specifically for doing that, called addItemToDepartment.0532

And what that is going to do is: because it is linking an item to a particular department,0537

and we know that that information is stored in that linking table depts_items, we are going to be creating an INSERT statement.0542

But it is going to be an INSERT statement in that depts_items linking table.0549

This method takes a deptID and an itemID as parameters.0554

It checks to make sure that both of those items exist in the database.0559

It checks to make sure that the item isn't already in a department, using this function that we had mentioned0563

that was developed in this version of the web application, which just tests if that pair already exists in the depts_items table.0568

If it already exists, it is just going to return true.0575

And then, if it doesn't already exist, and both the item and the department exist in the database, it is going to create this INSERT query.0578

And as you can see here, our INSERT query is saying, "Insert a row into the depts_items linking table0586

that is comprised of the deptID and item pair that was provided to this function."0595

And we go ahead and, because it is an INSERT query, we run the query using the query method.0602

We don't need to find out the number of rows that were returned.0609

We can just test this query method, which will return just true or false on whether the insert was successful or not,0613

because there is no insert_id that we are interested in; there is no AUTO_INCREMENT column.0618

We can just test that query returned true; if it returned true, then we would return true from this method,0622

saying that it was successfully added to the department.0629

If not, we are going to log an error, and then return false, saying that the item couldn't be added to the department.0631

That is how we add a department to our database.0637

And then also, that is how we add items to our department.0642

Now that we have a department in our database, one of the things that we want to do is check if the department exists.0650

And simply, the way that we do that is the same way that we do for an item.0657

We just write a query on the Departments table, asking if a row exists where the deptID is equal to a particular deptID.0662

If it returns a row, that means that the department does exist in the database, and we can return true or false.0671

And so, that is how that works.0678

Now, getDepartment is a little more complicated, because as mentioned, we have the data for a department spread across two different tables.0681

It is spread across the Departments table, and then it is also spread across the linking table depts_items.0689

We know a Department object has three properties: it has a deptID; it has a name; and it has an array called Items0694

that is an indexed array of all of the item ID's of all of the items in that particular department.0702

In order to get a department from the database, we need to build up that department object,0707

and that is what this getDepartment function is going to return.0711

It is going to return a built-up object that is going to include the deptID, the name of the department,0714

and then also that array of all of the items in the department.0719

We are going to have to run two SELECT queries.0723

The first SELECT query we run is on the Departments table.0727

And we are saying, "Give us a row in the table where the deptID matches the department we are trying to load."0730

We run the query, and then just test to make sure that one row is returned, because our deptID is a primary key, so we should only be getting one row.0738

Assuming that is true, then we have to take another step.0748

We know that the department exists in the Departments table; now, we need to find out if there are any items already in the department.0751

What we do is create another SELECT query; and in this query, we are just saying,0759

"Give us all of the values in the itemID column from the depts_items linking table0766

that have the deptID of the department we are searching for."0775

So, we are saying...for example, if we want to find all of the items in department 1...0778

"Give us the value of the itemID column for any rows that have the deptID equal to 1."0782

For example, if we take a look at the data in depts_items, we can see that our deptID 1 has two item ID's associated with it: 1001 and 1004.0789

What our query here that we were just looking at was: SELECT itemID from our linking table for department 1, for example.0808

So, we are saying, "Give us all the item ID's in a result set from this linking table where the column deptID equals 1."0823

So, we have two rows that are here, so we are going to get a result set that should have 1001 and 1004 in it.0833

And sure enough, when we run the query, that is what is going to happen.0837

That is what this query is going to do in our getDepartment function.0840

We are going to run the query, and then it is going to return a result set.0846

And that result set is going to be that MySQLi_Result object that allows you to call the fetch_object or fetch_array method on it,0849

that allows you to loop over each row returned in the result set.0858

What we are going to be able to do is loop over each row, and then pull out all the item ID's that are associated with that particular department.0863

Well, like for our getItem method, we have a private helper function within the DatabaseAccess class that we created, called buildDeptFromRows.0870

And what it does is builds up a Department object from the row returned when we ran this first query,0880

that gives us the name and department ID of the department.0887

And then, also, when we run the second query that is going to get the item ID's of all the items in the department,0891

that returns a result set object; we are going to pass that to this method, as well.0897

So, what is going to happen is: this private helper function is going to be able to extract information from the first query,0904

and then also extract all the item ID's from the result set of the second query.0910

If we go and look at the source code for this file, so we can see the private method,0915

we can see that buildDeptFromRows--what it does is tests to see if any rows exist0923

in that Items result set--meaning, "Were there any actual items in the department?"0929

If not, it just goes ahead and returns a Department object that contains the ID obtained from the row0934

that was returned from the Departments table query, and the name that was returned from the Departments table query,0940

and then an empty array for the Items, because no items are in it.0946

If that is not true, then what it does is: it is going to loop over the items result set that contains all of the itemID's of all the items in the department.0950

And what it is going to do is create this Items array, in which it is going to add the itemID of each row in that result set.0958

So, each row is going to have an itemID for each item in the department.0966

So, items will be built up; for department 1, for example, Items is going to contain two values.0970

It is going to contain 1001 and 1004.0975

And then now, we return a Department object that has the ID and name that were extracted from the Department row query results.0978

And then also, it is going to have set as its Items property that Items array.0989

We are going to have it set to this built-up array that we were able to build from our second query on the depts_items table.0994

getDepartments works the same way as our getItems does.1008

It goes through and runs a query (instead of on the Items table) on the Departments table.1012

And it is able to load a row for each department in the store.1018

And all we are going to do is (assuming that Departments exists in the database): we are going to create an array of Department objects,1023

and then replicate what we did in the getDepartment method that we just talked about.1032

For each row in the Departments table, we are going to go ahead and build up a Department object.1037

We are going to call the buildDeptFromRows helper function again.1046

We are going to pass it the row from the Departments table for each department.1050

And then, we are also going to pass it the result set, again, from that second query on our depts_items table.1055

It is going to build up this Items array and then return it.1062

And we are going to use that in a number of different spots--for example, in our left-hand navigation bar, we call it.1064

In our header.phtml, that calls this getDepartments method to load up all the Department objects to be able to list a link to each department.1069

It is also called on store.php: in the middle of the page, we have a list of all the departments.1081

And then also, in our admin site, when we have all of these dropdown boxes that list all of the departments,1085

that is where it is going to be used, as well.1090

Those are all of the different methods that we have added to move this department information into these two tables in our database,1093

to be able to insert department information, and then to be able to extract it.1101

So now, we are going to talk about how the script for this is used.1106

First, there is a script created called addDepartment.php; it is a new admin page that we have created1112

that is going to allow us to add a new department to the store database.1117

And as mentioned, it is going to be calling this insertDepartment function, which, as we learned, doesn't add any items to a particular department.1120

It just adds a row to the Departments table, so it is only going to take one value; it is going to take a name.1128

So, if we go and look at our new administrator site, there is a new link for addDepartment.1135

And it allows us to enter the name of the new department that we want.1143

For example, if we look at the store, and we refresh the homepage, the current status of the store1146

is that there are three different departments in the store.1152

And if we run a SELECT query on the Departments table, we can see that there are three departments in the store right now.1155

Well, with our new addDepartment page that is going to call this addDepartment function,1167

we can create a new department (we will call it Shoes), and we can add the department...or let's say Winter Clothes.1172

When we add the department to the store, it is going to let us know that it was added; it was assigned department 4.1186

Now, when we go back and run our Departments query again, we are going to see that it has been added to our Departments table.1192

When we go to view the store homepage again, we are going to see that it has been added to our homepage, and then also to the left navigation bar.1197

And then, when we click on it, it will take us to that department page.1206

And right now, it is going to show a table with no items in it; and that is because we haven't added any items to the store.1209

All we have done is created that row in the Departments table.1214

Well, we have updated our addItemToDepartment function to be able to add a row into that depts_items linking table.1217

So, let's add, for example, the winter jacket to the new Winter Clothes department (which, you can see, shows up in this dropdown box).1227

And when we add it to the department, it is going to let us know that it was successfully added.1234

If we go back to the store, we refresh the Winter Clothes page; we can see that it is now in there.1238

What is happening is: our addDepartment script is calling the insertDepartment method.1244

Our addItemToDepartment script is calling the addItemToDepartment method, which inserts a deptID/itemID pair within that linking table.1251

Our store pages are going to be calling the getDepartments method, which is going to load all the departments from the database up.1265

It is going to allow them to output links for them.1273

And then, we are also going to be able to...when we go to, for example, Department.php for deptID=4...1276

load a department; it is going to call the getDepartment function that we just created to load a department from the database,1285

which is going to get its name from the Departments table, and then all of the items in it,1291

which, in this particular case, is one, which is Winter Jacket.1294

And if we go and look at our depts_items linking table, we can see that we have a match here between deptID 4 and item 1004 (which is the Winter Jacket).1298

So, it has added that item to that department; it has added that pair to our linking table.1315

We saw about addItemToDepartment, which is that script that has those dropdown boxes, allows us to add the item to store, and calls that addItemToDepartment function.1326

Department.php is going to make use of, for example, the getDepartment function,1336

which is going to allow us to...when we click on our Winter Clothes department, that is what is going to allow us to pull up a department,1341

and then be able to output a row for each item in the department.1352

That is going to make use of the getDepartment function.1356

Our store.php page is going to use the getDepartments function, which allows us to get an array of all the departments in the store.1364

And then, our admin header.phtml has also been updated, so that it calls this new getDepartments method,1371

so that it can output the links on the side.1376

Additionally, our outputDeptSelector static method in the Output class, which is used to output the dropdown box1379

to select a department on our admin store, has been updated to use this new getDepartments method1386

to load all of the departments from the database.1392

And then, I just want to mention that, because all of our data now, as far as the store is concerned right now,1394

has been moved into a MySQL database, it is out of our flat file system.1400

We can get rid of departments.txt, and then we can also get rid of fileLIB.php, which...all that that contained,1404

in our last version, was functions related to getting a department, seeing if a department exists, and adding an item to a department.1413

Those have all been moved out, so fileLIB.php is gone.1420

So now, we have moved all of our item and department content into our database.1423

And our store is just running solely on MySQL database right now, as opposed to a combination of flat files and database.1430

Thank you for watching today's lesson; I look forward to seeing you next time.1436

Educator®

Please sign in for full access to this lesson.

Sign-InORCreate Account

Enter your Sign-on user name and password.

Forgot password?

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Sign up for Educator.com

Membership Overview

  • Unlimited access to our entire library of courses.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lesson files for programming and software training practice.
  • Track your course viewing progress.
  • Download lecture slides for taking notes.

Use this form or mail us to .

For support articles click here.