Databases
Can be proprietary like
›MS SQL Server or
›Oracle
Can be free open source like
›MySQL
Can be platform dependent like
›MS SQL Server (only on Windows NTs)
Can be platform independent like
›MySQL (Unix & Windows) and
›Oracle (Unix & Windows)
Can be Networked server – no fancy GUI
›MySQL
You can find clients that provide a GUI
›MS SQL Server (Built in)
›Oracle (with the help of Oracle Developer Suit)
Installation/Configuration
You install the server, and provide a root password.
Now you need a client to do anything!
›Create databases, view databases, etc.
Client Software
PHP MyAdmin
›A MySQL client written in PHP
Oracle Developer Suit
›You have to buy it to have flexibility on your database
Via the web you can manage:
›Manage Databases
›Manage users
›Submit queries (SQL)
A great way to learn SQL!
Convention
This is a function written in yellow (these are argument written in orange.
Opening a database
username=“fred”; password=“fred”;
database=“eiw”;
Function to connect with database
(server name,username,password);
Function to select database(database)
Submitting a query to the server
query = "SELECT uid from users WHERE username = ‘fred’";
result = function to execute query($query);
if (value of result is 0) {
… no result (error!)
}
or write( "Unable to select database");
Using the results of a query
In ASP/ODBC we used a recordset object to access the results of a query.
Mysql_query returns something similar – an object we can use to get at the rows of the result of the query.
Accessing
Function to count rows(result) : number of rows in the result.
Function to count get result(result,row number,column name)
rFunction to query a database(“SELECT * FROM users”);
if (result is not found) { …handle error…}
number of rows = function to find number of rows(result)
for (i=0;irows;i++) {
name = function to show result (result,i,”username”);
pass = function to show result(result,i,”password”);
… Do something with name and password…
}
No comments:
Post a Comment