Sunday, 13 November 2011

PHP with Mysql

Retweet this button on every post blogger
Mysql is the world's most popular open source database System ,with its superior speed, reliability, and ease of use, MySQL has become the preferred choice for Web, Web 2.0 today's millions  database based applications runs on mysql for their data storage needs, learning mysql is relatively easy and has a several advantage over other paid RDBMS software's.


PHP provide a large base of its function repository for handling mysql operation efficiently. these functions allow you to access MySQL database servers.

The structure of PHP and Mysql connectivity.
 
 As you can determine from the above diagram there is three boxes


  1. One is a client is running  a web Browser and making request to web server.
  2. Second is a Web server that handle clients request and make Appropriate request to Web Database software running at the extreme end of the structure it stores all the data. 
you can learn more about Mysql and can see its documentation at Mysql Reference .

If you have installed WAMP or XAMPP Bundle on your Ssystem Mysql comes with that automatically.

Five Important commands of MySQL.
  1. mysql_connect("host_name","User","Password") 
        this PHP function open's a MySQL Connection With the three parameters  passed  called.         host_name : - The name of host on which your server is running .
        user_name :- user name of the Database.
         password: - password of the database.

     2. mysql_select _db("db_name",resource link);
         Select the database with the provide resource returned by the mysql_connect() call, by                          default connect with the last opened coonection.
   
    3. mysql_query("Query",resource link)
        sends a unique query (multiple queries are not supported) to the currently active database on the     server      that's associated with the specified link_identifier.
   
    4. mysql_fetch_array(resource $result, $result_type)
        Fetch a result row as an associative array, a numeric array, or both
    5.  mysql_num_rows( resource $result )
         Get number of rows in result.retrieves the number of rows from a result set. This command is only         valid for statements like SELECT or SHOW that return an actual result set.