MySql Data Manager with OO PHP

Hello All,

Today, we are going to learn how to manage your data from mysql by php with the Object Oriented System. You know, this is very simple process to learn about this. So, lets start our work.

First of all, I have to make a page entitled index.php. Beside this, I made a database named mydata. In this database, I created a table called test with two column. One is id (int 11 auto increment) another is name (varchar 30). Now start to write our code with php class.

<?php

class dataManager{

    private static function __dbConnnect(){

        mysql_connect(“localhost”,”root”,””);        

        mysql_select_db(“mydata”);

    }

    

    

    public static function getUploadCount(){

        self::__dbConnnect();

        list($count) =  @array_values(mysql_fetch_assoc(mysql_query(“SELECT COUNT(*) FROM test”)));    

        return $count;

    }

}

echo “Number of Uploded :”.dataManager::getUploadCount();

?>

Now, browse your file and you will get the the output of Number of Uploded :–

That’s enough for today. Thanks to read this tutorial.

Bye

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s