Download presentation
Presentation is loading. Please wait.
1
PHP-language, database-programming
Jouni Juntunen Oulu University of Applied Sciences School of Business and Management Studies
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 API (Application programming interface)
Database-driver
4
Basic steps of database programming
Open connection to database-server and Select database Manipulate data 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
newMessage.html save.php
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 Select database to use
Servers may have several different databases
10
Manipulate data Reading information Inserting, updating and deleting
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.