PHP Programming. Topics Database Handling (MySQL, MSSQL, ODBC)

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.
Aqua Data Studio. Find the application We are using Aqua Data Studio v11.
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Databases and Connectivity MIS 497. Relational Databases Dominant database technology today. Dominant database technology today. Stores data in relational.
HOW TO CREATE DSN ON WINDOWS 7. Step 1. Click Start Step 2. Click Control Panel.
Tutorial SQL Server and Matlab CIS 526. Build a New Database in SQL server.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 11. DATABASE CONNECTIVITY IN JAVA JDBC Programming JDBC (Java Database Connectivity) is the specification of a.
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
Introduction to JDBC (Java Database Connectivity).
CIS 270—App Dev II Big Java Chapter 22 Relational Databases.
PHP Programming. Topics Background and History of PHP Installation Comments in PHP Variables Conditions Loops Functions File Handling Database Handling.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
CSCI 6962: Server-side Design and Programming
Class 3 MySQL Robert Mudge Reference:
JDBC Java Database Connectivity. What is an RDBMS? Relational database management system. There are other kinds of DBMS. Access is a GUI on a JET RBDMS.
Slide 8-1 CHAPTER 8 Using Databases with PHP Scripts: Using MySQL Database with PHP.
INTERNET APPLICATION DEVELOPMENT For More visit:
Analysis of SQL injection prevention using a proxy server By: David Rowe Supervisor: Barry Irwin.
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
Sayed Ahmed Computer Engineering, BUET, Bangladesh MSC, Computer Science, U of Manitoba, Canada
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
Concepts of Database Management Seventh Edition
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
Georgia Institute of Technology Making Text for the Web part 5 Barb Ericson Georgia Institute of Technology March 2006.
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Servlets Database Access. Agenda:  Setup Java Environment  Install Database  Install Database Drivers  Create Table and add records  Accessing a.
Database control Introduction. The Database control is a tool that used by the database administrator to control the database. To enter to Database control.
JDBC. JDBC stands for Java Data Base Connectivity. JDBC is different from ODBC in that – JDBC is written in Java (hence is platform independent, object.
Present :Arezoo Mollahasani. Step 1  Define your server connection Open MySQL WorkBench and click New Server Instance on the right of the window.
Session 7: Getting PHP to Talk to MySQL. Objectives Connecting to the Database Building & Executing the SQL SELECT Query Fetching & Displaying the data.
Accessing Database using JDBC. JDBC Objectives Gain basic knowledge of Java JDBC Become familiar with the basics of interacting with a database using.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database.
DATABASE TOOLS CS 260 Database Systems. Overview  Database accounts  Oracle SQL Developer  MySQL Workbench.
Presentation On How To Create Connection To A Database.
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
PHP and SQL Server: Connection IST2101. Typical web application interaction (php, jsp…) database drivers 2IST210.
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
Database Connectivity What is ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a Microsoft Active-X component.
>> PHP: MySQL & CRUD. R ecall Database Tables Records is composed of Operations (CRUD) Create Retrieve Update Delete DBMS Access Control MySQL phpMyAdmin.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 6: Accessing a database with PHP Rob Gleasure robgleasure.com.
Chapter 5 Building Your Product Catalog database Objectives Create Database. Create Table. Connect to Database. Use ASP Script to add new products. Use.
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.
Physical Layer of a Repository. March 6, 2009 Agenda – What is a Repository? –What is meant by Physical Layer? –Data Source, Connection Pool, Tables and.
Software-Projekt 2008 Seminarvortrag“Short tutorial of MySql“ Wei Chen Verena Honsel.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
How To Start a SQL server Connecting to SQL Server.
2 Copyright © 2008, Oracle. All rights reserved. Building the Physical Layer of a Repository.
ASP.NET Programming with C# and SQL Server First Edition
, MS-Access, QBE, Access/Oracle
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
W04 Connecting 3rd Party Application to ODBC
JDBC Database Management Database connectivity
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
Database Management  .
Aqua Data Studio.
VISUAL BASIC INTRODUCTION TO DATA CONNECTIVITY.
Introduction to Web programming
Presentation transcript:

PHP Programming

Topics Database Handling (MySQL, MSSQL, ODBC)

Database Handling PHP can connect to – MySQL – MSSQL – Access and other databases like oracle, postgre sql etc There are separate methods available for connecting to the databases

MySQL and MSSQL Connection mysql_connect(dbserver,userid,password) mssql_connect(dbserver,userid,password) – These methods are used for connecting to MySQL and MSSQL server using a userid and password $con = mysql_connect(‘localhost’,’root’,’root’); – This gets a connection to the local mysql server using the credentials root and root – If server cannot be connected, it will throw an error stating the problem Note: Mysql and MSSQL can be accessed in identical way except for the preceeding mysql or mssql. So will use mysql henceforth.

MySQL Select DB mysql_select_db(connection,dbname) mysql_select_db($con,”test”); – This will select the db test under the server localhost – If unable to select the database, an error will be thrown

MySQL Execute Query mysql_query(connection,sql statement); This will execute the sql statement on the database and store the result in a variable Eg – $rs = mysql_query($con,select stmt); – The rows of select statement will be stored in $rs – $row = mysql_fetch_array($rs); This will fetch a row and store in $row Values can be accessed like - $row[“ID”] – returns value of column ID in the fetched row.

MySQL and MSSQL Close To close a db connection we have close method – mysql_close(connection); – mssql_close(connection); Example – mysql_close($con); – mssql_close($con);

ODBC Data handling Connect to a data source – odbc_connect(dsn,uname,pwd); – DSN – Data Source Name – Go to Control Panel -> Administrative Tools -> Datasources (ODBC) – Click on ODBC and select System DSN tab. – Click Add and choose Access Database (mdb) and click Finish – In the dialog that appears, give DSN Name and Description

ODBC Data handling Contd.. – Click on Select under Database section – Choose a mdb (access database file) and give OK $conn=odbc_connect('nwind','',''); – Here nwind is the DSN that we have created in our system to access a database – We have not given any user name or password during DSN creation – So those fields are left empty.

Selecting rows from a table $rs = odbc_exec($conn,$sql); – $conn – connection string – $sql – SQL query to select rows from table – $rs is the result set of the query execution odbc_fetch_row($rs) – This command fetches row by row from the result set $cid = odbc_result($rs,"CustomerID"); – This command fetches value for the column CustomerID from the current row and stores it in the variable $cid.

Closing Connection odbc_close(connection) – This function closes the connection obtained and releases the same to the connection pool odbc_close($conn); – The connection defined by $conn is released and no query can be executed using this connection variable hence forth.