Geek Austin PHP Class - Session 4

  • 473 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
473
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
12
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Beginning PHP
    • Session #4
    • November 30, 2010
    Josh Butts
  • 2. Agenda
    • More sessions (briefly)
    • Database access, SQL
    • Creating a real login system for Vanity
  • 3. So, Databases...
    • This is what you’re really here for
    • PHP & Databases == Peanut Butter & Jelly
    • Databases will be your go to method for storing any sort of data for your application
  • 4. SQL
    • SQL = Structured Query Language
    • SQL is how we get data into and out of databases
    • Not really a programming language
    • Sort of standardized
  • 5. Queries
    • We write queries as plain text (strings in PHP)
    • We execute queries against a database
    • The database returns a Result Set
  • 6. Result Sets
    • Rows and columns of data that come out of a database
    • We loop over these to use them in PHP
    • We map these to associative arrays access our data
  • 7. Database Tables
    • One database has many tables
    • Think Excel workbook with many sheets
    • Tables have a schema
      • Named columns
      • Definition for what kind of data each column can store
  • 8. Columns
    • Mainly 2 types
      • Various types of strings
      • Various types of numbers
    • Definition is essentially “is it a string or a number, and how big will it be”
  • 9. Primary Keys
    • The “id” column
    • Usually an integer
    • Usually will automatically count up for you as you insert new rows
    • Must be unique values
  • 10. Disclaimer
    • For ease of use, we’re using SQLite, which is slightly different than MySQL
    • Some SQL for SQLite may not work on MySQL without a few tweaks
    • We’ll cover MySQL later
  • 11. SELECT queries
    • Gets data out of your database
    • Specifies:
      • What columns you want
      • What table to look at
      • What conditions to satisfy
  • 12. INSERT queries
    • Write new data to your database
    • Specifies:
      • The table to write to
      • Columns to be written to
      • Data for each column listed
  • 13. UPDATE queries
    • Changes existing data in your database
    • Specifies:
      • Table to write to
      • columns and values to update
      • How to find the rows to update (usually by primary key or “id”)
  • 14. DELETE queries
    • Delete data from the database
    • Specifies:
      • Which table to delete from
      • Conditions for which rows should be deleted