IS 337: Website Administration

Lecture for November 21: SQL

+
-

Topics

SQL Crash Course

  • Terminology: table, rows (data), columns (fields)
  • CREATE TABLE name ( fields ) toggle
    • fields is list of field_name datatype
  • SELECT columns FROM table WHERE conditions toggle
    • columns is list of columns from table or *
    • conditions is boolean expression of conditions on columns

Don't Edit Where You Make Money

  • Development server
  • Testing server
  • Staging server
  • Deployment server

Urlacher Shop

  • $inventory is ill advised toggle
    • Global variables are evil.
    • Function abstraction are much more flexible.
    • But what about efficiency?
  • Would like to search and sort proudcts. toggle
    • Using index in $inventory completely breaks down!
    • Using name of product wouldn't be smart. Why not?
    • Add our own primary key (real-world or internal).
  • Handling SQL injection: sqlite_escape_string($string)

Readings and Resources

Quick Written Assignment for Next Time

Write a PHP function to compare the costs of two items.

Creative © 2007 Calvin College and Jeremy D. Frens.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.