CS-GY 6083: Principles of Database Systems
1.0.0
1.0.0
  • Introduction
  • DBMS Basics
    • Introduction to DBMS
    • Why use a DBMS instead of a File System?
    • Levels of Abstraction
    • Instances and Schemas
  • Data Models
    • Introduction to Data Models
    • Database Languages
    • Database Design
  • DBMS Internals
    • Introduction to DBMS Internals
    • Storage Manager
    • Query Processor
    • Transaction Management
    • Database Users
    • Database Architecture
  • DBMS History
  • Some Popular Database Systems
  • OLTP, OLAP, and Data Mining
  • Databases vs. Information Retrieval
  • The Entity-Relationship Model - Details
    • Introduction
    • Cardinality Constraints
    • ER Diagram Components
    • ER Diagram to Relational Schema
    • Design Issues
  • The Relational Model - Details
    • Relations
    • Keys
    • Relational Query Languages
      • Relational Algebra
      • Relational Calculus
      • Relative Expressive Power
    • Relational Operators
  • SQL
    • Introduction to SQL
    • Domain Types in SQL
    • DDL Commands
      • Creating a Table
      • Alter and Drop
    • DML Commands
      • Basic Query Structure
      • Select
      • From
      • Where
      • Joins
      • Rename
      • String Operations
      • Ordering
      • Set Operations
      • Group By and Having
      • Nested Subqueries
      • Test for Empty Relations
      • Test for Duplicate Tuples
      • Derived Relations
      • With
      • Database Modification
    • Intermediate SQL
      • Joins Revisited
      • Views
      • Transactions
      • Integrity Constraints
      • More SQL Data Types and Schemas
        • Other Features
      • Authorization
    • Advanced SQL
      • Accessing SQL From a Programming Language
        • ODBC and JDBC
        • Embedded SQL
        • PHP
        • Some Security Issues
      • Accessing Metadata
      • Text Operations
        • Like
        • Contains
      • Cursors
      • Functions and Procedures
        • Procedural Constructs
        • External Language Routines
      • Triggers
      • Ranking
      • Windowing
      • OLAP
Powered by GitBook
On this page

Was this helpful?

  1. SQL
  2. Advanced SQL
  3. Accessing SQL From a Programming Language

PHP

PHP is a server-side scripting language.

It was mainly developed for the web but can also be used as a general-purpose programming language.

PHP works well with MySQL and can be used in combination with HTML to create a webapp that connects to a database.

Working:

  1. web browser sends HTTP requests and receives HTTP responses

  2. PHP script (on the server-side) connects to DBMS and uses query results to produce its output

  3. web server calls the PHP script and incorporates its output into the response

  4. web browser renders the HTML document from the response

Executing SQL from PHP:

  1. connect to server (mysql_connect)

  2. select the database (mysql_select_db)

  3. run query

  4. retrieve row of results (mysql_fetch_array)

  5. retrieve attributes (foreach)

A typical web-app will have the following components:

  • Login page:

    Collect credentials and pass them to setup page via POST

  • Setup page:

    • Check credentials

    • Initialize session and session variables

    • Redirect to welcome page

  • Application pages:

    Call session_start(), authenticate the session, and use/ update session variables, as needed

  • Logout page:

    • Calls session_destroy()

    • Redirects to “goodbye” page

PreviousEmbedded SQLNextSome Security Issues

Last updated 5 years ago

Was this helpful?