What is PHP?
PHP is a general purpose server side scripting language that we can use to develop dynamic web sites and applications. PHP only needs to be installed on the web server that will host the web application and client applications can access the server resources via web browsers. The diagram shown below illustrates the basic architecture of a PHP web application.Why PHP?
You have obviously head of a number of programming languages out there; you may be wondering why we would want to use PHP over other languages to develop our video library application? PHP just like MySQL is open source and free, you don't need to pay for you to get PHP; all you have to do is download it. Packages such as XAMPP come bundled already with a web server, MySQL and PHP among others. This is also unbelievably free. This makes PHP a cost effective choice compared to other scripting languages such as CFML or ASP.Other benefit that you get with PHP is that it's a server side scripting language; this means you only need to install it on the server and client computers requesting for the resources from the server do not need to have PHP installed; only a web browser would be enough.
PHP also has in built support for working hand in hand with MySQL; this doesn't mean you can't use PHP with other database management systems.
PHP is cross platform which means you can deploy your application on a number of different operating systems such as windows, Linux, Mac OS etc.
PHP and MySQL
PHP and MySQL are like two different sides of the same coin. Just like MySQL has built in functions for data manipulations, so does PHP has built in functions for connecting to MySQL server and manipulating the data in the database. Let's now look at some of PHP functions that allow us to manipulate MySQL databasesMySQL connect
$dh = mysql_connect(servername,username,password);
- "mysql_connect" is the PHP built in function for connecting to MySQL database
- "servername" is the name of the server running MySQL server.
- "username" is the name of the user that we will use to authenticate ourselves when connecting to the server.
- "password" is the password that we will use to authenticate ourselves when connecting to the server.
Alternatively we can also use the PHP Data Object PDO to connect to MySQL server. It has the following basic syntax.
$dbconn = new PDO(mysql:host=servername;dbname=databasename,username,password);
- "dbconn" is the database connection object that we can use to manipulate our database.
- "new PDO (...)" creates an instance of the PDO class.
- "mysql:host=servername;" is the name of the server running MySQL server.
- "dbname=databasename" is the name of the database to be manipulated from PHP.
- "username,password" are login credentials we will use to authenticate ourselves.
Introducing Myflix Video Library Application
Assuming we have acquired knowledge of the PHP language combined with what we just learnt in the MySQL tutorial series, we can write the web based application in PHP that runs on top of the MySQL database to provide our Myflix database users with a Visual Graphical User Interface for interactions.Myflix Video Library Screenshots
The screenshots below show how the video library application running on top of Myflixdb would look like.Members listing window shown above
Movie details editing window shown above
Summary
- MySQL is a powerful open source database engine that can meet the requirements of both stand-alone as well as client server applications.
- PHP is a general purpose scripting language that can be used to develop client applications that run on top of MySQL databases.
- Equipping yourself with both MySQL and PHP knowledge is double blessing.
0 comments:
Post a Comment