Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP-language, database- programming Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management.

Similar presentations


Presentation on theme: "PHP-language, database- programming Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management."— Presentation transcript:

1 PHP-language, database- programming Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management

2 Idea of database programming End users do not use database from management console using SQL-statements Create UI (web-page, windows form, etc.) for end user and permorm database manipulation in application code (e. g. in PHP-script)

3 Database programming Database-driver Database-programming API (Application programming interface) Application

4 Basic steps of database programming 1.Open connection to database-server and Select database 2.Manipulate data 3.Close connection

5 Example: Read data from database

6 mysql_fetch_row Structure of the table in database Data (records) of the table in database mysql_fetch_row read one record at time and the return value is array containing information of all fields

7 Example: Insert data into database save.php newMessage.html

8 Opening connection Connection to database server must be opened before manipulating data Check always for error when opening database connections

9 Select database to use Servers may have several different databases

10 Manipulate data Reading information – mysql_query containing select sql-statement – mysql_fetch_row inside while loop Inserting, updating and deleting – mysql_query containing sql-statement that manipulates data

11 Close connection Connection to database (server) must be always closed after manipulatin data Open connections consumes resources from server


Download ppt "PHP-language, database- programming Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management."

Similar presentations


Ads by Google