Mark Dixon Page 1 23 – Object Oriented Programming in PhP.

Slides:



Advertisements
Similar presentations
Lilian Blot Announcements Teaching Evaluation Form week 9 practical session Formative Assessment week 10 during usual practical sessions group 1 Friday.
Advertisements

An Introduction to Hashing. By: Sara Kennedy Presented: November 1, 2002.
Mark Dixon, SoCCE SOFT 131Page 1 15 – Object Oriented Analysis, Design, and Programming.
Mark Dixon, SoCCE SOFT 131Page 1 22 – Object Oriented Analysis, Design, and Programming.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Mark Dixon Page 1 16 – Passing Data between pages: Forms, Sessions, & Query Strings.
Mark Dixon Page 1 05 – Database Design: Sub-forms.
Mark Dixon Page 1 04 – Database Design: Forms. Mark Dixon Page 2 Session Aims & Objectives Aims –To allow easier data entry using forms Objectives, by.
Mark Dixon Page 1 22 – Object Oriented Programming in ASP.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
Mark Dixon, SoCCE SOFT 131Page 1 13 – Object Oriented Analysis, Design, and Programming.
Mark Dixon, SoCCE SOFT 131Page 1 07 – Iterative Execution.
PHP (2) – Functions, Arrays, Databases, and sessions.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2010 All Rights Reserved.
Mark Dixon Page 1 07 – Reports. Mark Dixon Page 2 Session Aims & Objectives Aims –To use reports to produce more readable documents Objectives, by end.
Mark Dixon Page 1 21 – Object Oriented Programming in ASP.
Mark Dixon, SoCCE SOFT 131Page 1 08 – Iterative Execution.
Mark Dixon Page 1 02 – Queries: Query by Example.
Mark Dixon Page 1 13 – Object Oriented Programming.
Mark Dixon Page 1 20 – Web applications: Writing data to Databases using ASP.
ASP.NET Programming with C# and SQL Server First Edition
Object Oriented Software Development Modelling business objects OOSAD Booklet Chapter 4 Lecture: Week 4 Brian Farrimond.
C++ fundamentals.
Database Systems Lecture 5 Natasha Alechina
CPT 140 Programming Constructs1 OBJECT ORIENTED TECHNOLOGY Terminology and Basic Concepts.
Object Oriented Software Development
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Mark Dixon Page 1 10 – Iterative Execution. Mark Dixon Page 2 Questions: Variables Write a line of code to declare a variable called h Write a line of.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
Mark Dixon Page 1 24 – Object Oriented Programming in ASP.
SHOPPING CARTS CHAPTER 19. E-COMMERCE Typically, an e-commerce site will have public pages and admin pages.
Mark Dixon 1 22 – Web applications: Writing data to Databases using ASP.Net.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using ASP.
Mark Dixon, SoCCE SOFT 136Page 1 9 – Procedures. Mark Dixon, SoCCE SOFT 136Page 2 Session Aims & Objectives Aims –To introduce the main concepts involved.
Mark Dixon Page 1 18 – Web applications: Server-side code (PhP)
Mark Dixon Page 1 21 – Persistent data storage: relational databases and MySQL.
1 Classes and Controls CE-105 Spring 2007 By: Engr. Faisal ur Rehman.
Mark Dixon 1 03 – Passing Data between pages: Forms, Sessions, & Query Strings.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
© Anselm Spoerri Web Design Information Visualization Course Prof. Anselm Spoerri
Requirements Engineering Methods for Requirements Engineering Lecture-30.
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Mark Dixon, SoCCE SOFT 131Page 1 24 – Datatypes and Object Association.
DT228/3 Web Development Databases. Querying a database: Partial info Search engines, on-line catalogues often need to allow user to search a database.
Learners Support Publications Object Oriented Programming.
Mark Dixon SOFT 131Page 1 12 – Object Oriented Analysis, Design, and Programming.
Mark Dixon 1 22 – Object Oriented Programming. Mark Dixon 2 Questions: Databases How many primary keys? How many foreign keys? 3 2.
Mark Dixon Page 1 15 – Structured Programming. Mark Dixon Page 2 Admin: Coursework 3 – Test In class test –9 Feb 2010 –2 Feb 2010: revision (technique)
CPS120: Introduction to Computer Science Lecture 16 Data Structures, OOP & Advanced Strings.
Mark Dixon, SoCCE SOFT 131Page 1 17 – Procedures.
Working With Database Library And Helpers. Connecting to your Database First you need to set parameters in you database.php file residing in config folder.
Mark Dixon 1 15 – Structured Programming. Mark Dixon 2 Admin: Test 2 In class test –11 Feb 2014 –4 Feb 2014: revision (technique) session 50 mins short.
Mark Dixon 1 13 – Parameters. Mark Dixon 2 Question: Arrays How many array variables are in the following code: Dim x Dim y Dim f(4) x = 12 y = 6 f(2)
Mark Dixon, SoCCE SOFT 131Page 1 25 – Soft 131 Examination Revision.
Mark Dixon 1 Soft051 Examination Sample Questions.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Mark Dixon Page 1 09 – Iterative Execution. Mark Dixon Page 2 Questions: Variables Write a line of VBScript code to declare a variable called h Write.
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
CE-105 Spring 2007 By: Engr. Faisal ur Rehman
15 – Structured Programming
12 – Object Oriented Programming
23 – Object Oriented Programming in ASP
Database Fundamentals
CPS120: Introduction to Computer Science
Tutorial 6 PHP & MySQL Li Xu
19 – Databases: Multiple Tables
Updating Databases With Open SQL
Updating Databases With Open SQL
Presentation transcript:

Mark Dixon Page 1 23 – Object Oriented Programming in PhP

Mark Dixon Page 2 Questions: HTML in PhP Are these correct (assume variables and fields exist)? $s = $s.. $r["Model"]; $s = $s $r["Length"]; $h = " ". $h. " ";  

Mark Dixon Page 3 Questions: SQL in VB Are these correct (assume variables and fields exist)? $id = 4; $sql = SELECT * FROM Customer; $sql = $sql " WHERE CustID = ". $id;  

Mark Dixon Page 4 Questions: Writing to Databases What SQL statement adds a new record to a database table? What SQL statement removes a record in a database table? What SQL statement changes data in a record? INSERT DELETE UPDATE

Mark Dixon Page 5 Session Aims & Objectives Aims –To introduce object oriented techniques in PhP Objectives, by end of this week’s sessions, you should be able to: –create a class definition in server-side code –create an instance of a class –create a class definition from a class diagram

Mark Dixon Page 6 Object-Oriented Paradigm A program is made up of a number of objects that communicate with each other by passing messages Each object contains –attributes/properties that represent its state, and –operations/methods that represent its behaviour Objects often mirror the real world –Customers –Students –Patients

Mark Dixon Page 7 Classes and Instances Object Classes –general descriptions of types of objects, e.g. student, product, customer, lecturer, and room. Object Instances –specific items of a given class, e.g. each of you could be an instance of the student class Room 214 could be an instance of the room class I could be an instance of the lecturer class Bolt could be an instance of the part class

Mark Dixon Page 8 Object Concepts - Implementation Properties – implemented as –data structures (variables, arrays, and types). Methods – implemented as either –a procedure (to perform some processing), or –a function (to return a value). Object oriented paradigm builds on (rather than replaces) the structured paradigm

Mark Dixon Page 9 Class Diagrams Used to describe structure of object classes: Module Code: string Title: string GetTitle(): string SetTitle(t: string) Count(): integer Class Attributes/Properties Class Operations/Methods Class Name

Mark Dixon Page 10 class Module{ var $Code; var $Title; function GetTitle(){ return $this->Title; } function SetTitle($t){ $this->Title = $t; } function Count(){ return 50; } Implementing Class Diagrams Module Code: String Title: String GetTitle(): string SetTitle(t: string) Count(): integer

Mark Dixon Page 11 Benefits of OOP in code Procedures and Functions are part of object –encapsulation Related Data and Operations together Clearer code Less prone to error

Mark Dixon Page 12 Example: Counter (html) Counter <?php echo $Msg; ?>

Mark Dixon Page 13 Example: Counter (code) <?php session_start(); if(isset($_SESSION["c"])){ $c = $_SESSION["c"]; if(isset($_POST["btnReset"])){ $c->Reset(); }elseif(isset($_POST["btnUp"])){ $c->Up(); }elseif(isset($_POST["btnDown"])){ $c->Down(); } $Msg = $c->GetCount(); }else{ $_SESSION["c"] = new Counter; $Msg = ""; } ?> <?php class Counter{ var $mCount; function GetCount(){ return $this->mCount; } function Reset(){ $this->mCount = 0; } function Up(){ $this->mCount = $this->mCount + 1; } function Down(){ $this->mCount = $this->mCount - 1; } ?> Counter.php

Mark Dixon Page 14 Questions: OOP How many –classes –properties –methods –functions –procedures <?php class Counter{ var $mCount; function GetCount(){ return $this->mCount; } function Reset(){ $this->mCount = 0; } function Up(){ $this->mCount = $this->mCount + 1; } function Down(){ $this->mCount = $this->mCount - 1; } ?>

Mark Dixon Page 15 Tutorial Exercise: Counter Task 1: Get the Counter example from the lecture working. Task 2: Modify your code – so that the value cannot go below 0 or above 10.