PowerPoint Slide 1


PowerPoint Slide 2


PowerPoint Slide 3


PowerPoint Slide 4

Making $dbh global allows it to live outside of the encapsulated function

PowerPoint Slide 5
? Is a wildcard

Using a prepared statement is more secure and can lead to performance increases in cases where a single query is used repetitively.

PowerPoint Slide 6

The '?' and ':artist_id' signify place holders.
When you do:
$artist_stm = $dbh->prepare($sql_artist)
Prepare sees these place holders and returns a PDO statement which incorporates these placeholders and can be executed. When you call execute on the statement you give it an array that fills in the placeholders.

Also note the order of insertion here - Artist before Album. The Artist record is inserted before the Album since Album has a foreign key that references Artist.

PowerPoint Slide 7


PowerPoint Slide 8


PowerPoint Slide 9


PowerPoint Slide 10


PowerPoint Slide 11


PowerPoint Slide 12
LIMIT restricts number of entries on page, OFFSET refers to row in table to start listing those entries From what I understand, $offset is essentially where the list will start from, i.e. if the offset is 0 the entries returned will start at the first element, if the offset is 6 the entries will start at the seventh element. In this example the offset looks like is more or less hardcoded to always be a multiple of 25.
PowerPoint Slide 13


PowerPoint Slide 14


PowerPoint Slide 15

The 'LIKE' command tells the search to look for things matching the pattern between the % signs.