Database Systems Fundamentals

Similar documents
Database Systems Fundamentals

WINTER. Web Development. Template. PHP Variables and Constants. Lecture

Database Systems Fundamentals

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel

PHP: Hypertext Preprocessor. A tutorial Introduction

PHP 5 Introduction. What You Should Already Know. What is PHP? What is a PHP File? What Can PHP Do? Why PHP?

What is PHP? [1] Figure 1 [1]

Part I. Web Technologies for Interactive Multimedia

CS 377 Database Systems. Li Xiong Department of Mathematics and Computer Science Emory University

PHP. Interactive Web Systems

Options. Real SQL Programming 1. Stored Procedures. Embedded SQL

COMS 469: Interactive Media II

COMP284 Scripting Languages Lecture 9: PHP (Part 1) Handouts

PHP Hypertext Preprocessor

B. V. Patel Institute of BMC & IT 2014

Lecture 7 PHP Basics. Web Engineering CC 552

Web Scripting using PHP

UFCEKG Lecture 4 Server Side Scripting & PHP

Introduction to PHP (PHP: Hypertext Preprocessor)

Lecture 12. PHP. cp476 PHP

PHP: The Basics CISC 282. October 18, Approach Thus Far

Functional Programming. Pure Functional Programming

PHP and MySQL for Dynamic Web Sites. Intro Ed Crowley

PHP by Pearson Education, Inc. All Rights Reserved.

CS 31: Intro to Systems C Programming. Kevin Webb Swarthmore College September 13, 2018

Introduction of PHP Created By: Umar Farooque Khan

CS 314 Principles of Programming Languages

Web Engineering (Lecture 08) WAMP

Databases on the web

Key Differences Between Python and Java

SQL Injection Attack Lab

quiz 1 details wed nov 17, 1pm see handout for locations covers weeks 0 through 10, emphasis on 7 onward closed book bring a , 2-sided cheat she

PHP Online Training. PHP Online TrainingCourse Duration - 45 Days. Call us: HTML

MySQL: Querying and Using Form Data

INTERNET PROGRAMMING. Software Engineering Branch / 4 th Class Computer Engineering Department University of Technology

Midterm Review Topics Java Basics and Structure Variables Branching Loops Methods Arrays. Midterm Review Kage Weiss Lab 001 TA, SPR 17

Server side basics CS380

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

CPSC 481: CREATIVE INQUIRY TO WSBF

PHP INTERVIEW QUESTION-ANSWERS

PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37)

Lecture (05) PHP 01. By: Dr. Ahmed ElShafee. Dr. Ahmed ElShafee, ACU : Spring 2016, Web Programming

Course Syllabus. Course Title. Who should attend? Course Description. PHP ( Level 1 (

PHP for PL/SQL Developers. Lewis Cunningham JP Morgan Chase

Server-side web security (part 2 - attacks and defences)

Agenda. 1. Brief History of PHP. 2. Getting started. 3. Examples

COMP284 Scripting Languages Lecture 14: JavaScript (Part 1) Handouts

A QUICK GUIDE TO PROGRAMMING FOR THE WEB. ssh (then type your UBIT password when prompted)

PHP APIs. Rapid Learning & Just In Time Support

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

Perl Basics 7 Mar 2009 #fedora-classroom. Doran Barton

Chapter 7:- PHP. Compiled By:- Sanjay Patel Assistant Professor, SVBIT.

Chapters 10 & 11 PHP AND MYSQL

Introduction to Python

SAP PRESS Essentials. Guide to PHP. Craig S. Cmehil

CERTIFICATE IN WEB PROGRAMMING

Quick Introduction to PHP

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users

Basic PHP Lecture 17

URLs and web servers. Server side basics. URLs and web servers (cont.) URLs and web servers (cont.) Usually when you type a URL in your browser:

CHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS

PHP 1. Introduction Temasek Polytechnic

Using PHP with MYSQL

Basic PHP. Lecture 19. Robb T. Koether. Hampden-Sydney College. Mon, Feb 26, 2108

Fachgebiet Technische Informatik, Joachim Zumbrägel

CSC Web Programming. Introduction to JavaScript

Babu Madhav Institute of Information Technology, UTU 2017

PHP. Introduction. PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++

PHP Development - Introduction

PHP and MySQL. Introduction. General

6.001: Structure and Interpretation of Computer Programs

Decaf Language Reference Manual

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

EasyChair Preprint. Introduction to Development of Software Support for Training and Testing IT Administrators

PHP Introduction. Some info on MySQL which we will cover in the next workshop...

CMPS 401 Survey of Programming Languages

Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel

Quiz 1 Review Session. November 17th, 2014

A Fast Review of C Essentials Part I

Windshield. Language Reference Manual. Columbia University COMS W4115 Programming Languages and Translators Spring Prof. Stephen A.

PHP is a scripting language used primarily on Web

DM550 Introduction to Programming part 2. Jan Baumbach.

Web Scripting using PHP

Lecture Notes on Safety and Information Flow on the Web: II

CEU s (Continuing Education Units) 12 Hours (i.e. Mon Thurs 5 9PM or Sat Sun 8AM 5PM)

Computer Components. Software{ User Programs. Operating System. Hardware

CS 320: Concepts of Programming Languages

2 rd class Department of Programming. OOP with Java Programming

CHAPTER 5 1 RECORDS MANAGEMENT

Java Basic Programming Constructs

Database and MySQL Temasek Polytechnic

Data abstraction, revisited

Lecture 1: Hello, MATLAB!

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

CS 3360 Design and Implementation of Programming Languages. Exam 1

PROGRAMMING FUNDAMENTALS

Some things to watch out for when using PHP and Javascript when building websites

15.1 Origins and Uses of Ruby

Transcription:

Database Systems Fundamentals Using PHP Language Arman Malekzade Amirkabir University of Technology (Tehran Polytechnic) Notice: The class is held under the supervision of Dr.Shiri github.com/arman-malekzade arman.malekzade@aut.ac.ir

Chapter 3- HTML & PHP Roadmap : Hypertext Markup Language Hypertext Preprocessor Variables, Constants, Data Types Arrays Functions Conditional Statements Loops Object-Oriented (Classes) PDO

Hypertext Preprocessor Designed primarily for web development Originally created by Rasmus Lerdorf in 1994 The PHP interpreter, is itself written in C An HTML-embedded Web scripting language Originally stood for "Personal Home Page Zeev Suraski and Andi Gutmans, rebuilt PHP's core, releasing the updated result as PHP/FI 2 in 1997. The acronym was formally changed to PHP: HyperText Preprocessor, at this time. PHP Language 1

Variables in PHP Formal Definition: $var_name=value; A variable name must start with a letter or the underscore character. A variable name cannot start with a number. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and ) Variables are case sensitive. Var. Cons. Data types 2

Constants in PHP Formal Definition: define( cons_name,value); A constant is an identifier (name) for a simple value. That value cannot change during the execution of the script By convention, constant identifiers are always uppercase. The name of a constant follows the same rules as any label in PHP. Var. Cons. Data types 3

Constants in PHP: Magical Constants FUNCTION The function name DIR The directory of the file CLASS The class name METHOD FILE The class method name The full path and filename of the file with symlinks resolved Var. Cons. Data types 4

PHP Data Types String Integer Float (floating point numbers - also called double) Boolean Array Object NULL Resource var_dump is used to find the type of a variable. Ex: Code : $txt= hello ;var_dump($txt); Output: string(5) Var. Cons. Data types 5

Arrays in PHP Formal Definition: $arr_name=array(values); Ex: $simple_array=array(1,2,3,4,5,6); Is equivalent to $simple_array=array( 0 =>1, 1 =>2,, 5 =>6); Associative arrays can be treated like a hashmap. They can also be considered as a stack! Ex: array_push($simple_array, new_value, another new value ); Ex: array_pop($simple_array); Var. Cons. Data types 6

Arrays in PHP: Associative Arrays Array Elements Alice Bob Fred Tasha 0 1 2 3 Array Indexes Var. Cons. Data types 7

Arrays in PHP There are 3 kinds of arrays in PHP 1. Numeric (Like C Language) Ex: $arr=array(1,2,3,4,5,6); 2. Associative (Hash Tables) Ex: $assoc_arr=array( name => Tasha,Code=>15); 3. Multi-dimensional (Like C Language) Ex: $md_arr=array( array(1,2,3), array(4,5,6), array(7,8,9) ); HTML Intro 8

PHP Functions Ex: Definition: function concat($param1,$param2){ // pass by value return $param1.$param2; Call : echo concat( hello, world ); Definition: function increment(&$param){ // pass by reference $param += 1; Call: $x=1; increment(&$x); //x becomes 2 Functions 9

PHP Conditional Statements Example: If($x > 1){ echo its greater than 1 ; elseif($x==1){ echo its equal to 1 ; else{ echo its less than 1 ; switch($x){ case 1: echo its 1 ; break; case 2: echo its 2 ; break; default: echo none ; Cond. St. & Loops 10

PHP Loops Example: while($x>1){ echo its greater than 1 ; do{ $x=$x+1; while($x>1); for($i=1;$i<10;$i++){ echo $x; Cond. St. & Loops $arr=array(1,2,3); foreach($arr as $element){ echo $element; foreach($arr as $key=>$val){ echo $key.. $val; 11

PHP OP: Classes Example: class user{ protected $name; protected $age; function user($name,$age){ $this->name=$name; $this->age=$age; function set_name($str){ $this->name=$str; OP & PDO class student extends user{ protected $avg; function get_avg(){ return $this->avg; function update_avg($avg){ $this->avg=$avg; 12

PHP Data Objects 1. Establish a connection to the server $conn = new PDO( mysql:host=$servername;dbname=$dbname;charset=utf8", $username, $password); 2. Prepare a statement $stmt = $conn->prepare( INSERT INTO users (name,picture) VALUES (:name,:picture) ); $stmt = $conn->prepare( SELECT * FROM $table_name WHERE ID=:id ); 3. Bind Parameters $stmt->bindparam( :name,$name);$stmt->bindparam( :picture,$picture); $stmt->bindparam( :id,$id); 4. Execute the Query $stmt->execute(); 5. Fetch Result(s) [If Needed] $result=$stmt->fetch(pdo::fetch_assoc); //the result is an associative array OP & PDO

References [1] PHP Cookbook - O Reilly Media shop.oreilly.com/product/0636920029335.do [2] Constants - Retrieved Mar 6, 2017 from http://php.net/manual/en/language.constants.php [3] PHP 5 Variables - Retrieved Mar 6, 2017 from www.w3schools.com/php/php_variables.asp [4] The History of PHP - Retrieved Mar 6, 2017 from http://www.nusphere.com/php/php_history.htm References