PHP and MySQL Code Reuse, OO, Error Handling and MySQL (Intro)

Slides:



Advertisements
Similar presentations
The Relational Model and Normalization (1)
Advertisements

PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
Introduction to Databases
File Systems and Databases
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
PHP and MySQL Code Reuse, OO, Error Handling and MySQL (Intro)
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
N. J. Taylor Database Management Systems (DBMS) 1.
MySql In Action Step by step method to create your own database.
Introduction To System Analysis and design
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
CSCI 6962: Server-side Design and Programming
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
1 Intro to Info Tech Database Management Systems Copyright 2003 by Janson Industries This presentation can be viewed on line at:
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Introduction to SQL Steve Perry
Shaowen Wang CyberInfrastructure and Geospatial Information Laboratory (CIGI) Department of Geography and National Center for Supercomputing Applications.
Databases. Database A database is an organized collection of related data.
PHP meets MySQL.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
1 Working with MS SQL Server Textbook Chapter 14.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 4th Edition Copyright © 2009 John Wiley & Sons, Inc. All rights.
PHP and MySQL CS How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.
Object-Oriented Programming (OOP) CSC-2071 (3+1=4 Credits) Lecture No. 1 MBY.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
1.NET Web Forms Business Forms © 2002 by Jerry Post.
FEN  Data Definition: CREATE TABLE, ALTER TABLE  Data Manipulation: INSERT, UPDATE, DELETE  Queries: SELECT SQL: Structured Query Language.
Object-Oriented Programming
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
If you need to use some information that is not contained in one of the pre-selected tables, you can find out where that data is stored through the Banner.
Object Oriented Database By Ashish Kaul References from Professor Lee’s presentations and the Web.
Database Management Systems (DBMS)
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Presented by Vishy Grandhi.  Architecture (Week 1) ◦ Development Environments ◦ Model driven architecture ◦ Licensing and configuration  AOT (Week 2)
Misc Odds and Ends CSCI 297 Scripting Languages. Today 1.Database Normalization 2.Data Backups 3.Tracking the User with Cookies 4.Short example of SQL.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 1: Introduction to IS2803 Rob Gleasure
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
Signing a Document Digitally Click when you are ready to begin the tutorial.
1 CS 430 Database Theory Winter 2005 Lecture 7: Designing a Database Logical Level.
CS4432: Database Systems II
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Introduction to Database Programming with Python Gary Stewart
LEARNING SERVICES. LEARNING SERVICES Learning Resources As a student of Edge Hill University you have a wealth of resources available to help you complete.
Chapter 5 Introduction to SQL.
CS320 Web and Internet Programming SQL and MySQL
Databases.
Object-Oriented Database Management System (ODBMS)
Introduction to CodeIgniter (CI)
Section 11.1 Class Variables and Methods
BASIC PHP and MYSQL Edward S. Flores.
Computer Programming.
Database Fundamentals
File Systems and Databases
Teaching slides Chapter 8.
Developing a Model-View-Controller Component for Joomla Part 3
ITEC 3220A Using and Designing Database Systems
Introduction to Data Structure
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

PHP and MySQL Code Reuse, OO, Error Handling and MySQL (Intro)

require() and include() Software Engineering tenets tell us to reuse code rather than write new code. – Lower Cost – Increased reliability (in theory!) – Improved consistency Code reuse in PHP (home.html vs home.php) – require(‘ ’) – include(‘ ’)

Object-Orientation What is it? – Classes – defines abstract characteristics of a thing State (data) Behavior (procedure/methods) Identity (unique identifier for an instance of the class) – Polymorphism - ability to create a variable, a function, or an object that has more than one form Dog, cat and bird can all “talk” but does so differently. Same function call, different result. Operator overloading – (+, -, * and /) can be performed differently in classes. – Inheritance – create a new class as an extension of an existing class class Student extends Person

Object Orientation in PHP home.php and services.php Both use Page class defined in page.inc Very simple to create and rapidly deploy pages with the same look and feel services.php uses inheritance to extend Page class to reuse code and only add code that is unique to that page!

Exception Handling Exception handling - mechanism designed to handle the occurrences that change the normal flow of program execution. Basic Concepts – try { //code goes here } – catch{ //handle exception} Back to Bob’s Auto Parts… – Handling file open exceptions…

MySQL SQL – Structured Query Language – Based on Relational Algebra Data is structured into: – Databases – a group of related tables – Tables – a container of related Tuples – Tuples – a set of individual values – Keys – a way to uniquely identify tuples

MySQL To create tables you need to be familiar with Database Normalization – Gather like data together to form a table – Look to avoid anomalies and wasted space Insertion anomaly Modification anomaly Deletion anomaly – Atomic values – each column stores only 1 instance of a type of information

MySQL Choose sensible keys – A key of a last name will limit your customer base! Think about what you want to ask the DB – make sure you capture the info to answer the questions! – What are my top sellers? – Who are my best customers? Avoid designs that create empty column – Books(ISBN, Author, Title, Price, Review)

MySQL DB Design Use the KISS rule. – Create tables that mirror real world objects – Avoid anomalies – Keys can be used to link tables together

MySQL Accessing your CISC474 MySQL database… – A database has been created for each of you to use. – Username/DB Name: Your ECE/ACAD username OR first initial/last name (John Smith = jsmith). – Password: Your username + last 4 digits of your Student ID… Change it ASAP to something easy to remember but difficult for others to guess… Do not use a password that you would not either the TA or myself to see since you will need to enter it into PHP scripts!

MySQL Change password: SET PASSWORD = PASSWORD(‘newpass’); Great source for MySQL (we are using version 5.1) – tml tml

MySQL - Creating tables Logon to cisc474.acad.cis.udel.edu mysql –u -p – You will be prompted for your password To open your mysql db type use