Ar the man

PHP: Database Manager

interface DataBaseManager{
	public function connect();
	public function shutdown();
}

class DatabaseCommon{
	public function common_function_call(){
		print "Function common to mySql and Oracle ...";
	}
}

class mySql extends DatabaseCommon implements DataBaseManager{
	public function connect(){
		print "Connection mySql is establish ...";
	}

	public function shutdown(){
		print "Connection to mySql is destablish";
	}
}

class myOracle extends DatabaseCommon implements DataBaseManager{
	public function connect(){
		print "Connection Oracle is establish ...";
	}

	public function shutdown(){
		print "Connection to Oracle is destablish";
	}
}

class DatabaseFactory{
	public static function initialize_to( $class ){
		if(class_exists($class)) return new $class(); die ("Class Not Found $id");
	}
}


/* much better approach As you can see you can separate common functionality in another class DatabaseCommon. This help you to aviod changing both mySQl and Oracle class and interface class when want add more functions.*/

$mydb = DatabaseFactory::initialize_to('myOracle'); $mydb->connect(); $mydb->common_function_call(); $mydb->shutdown();


Comments

Comments

How to install PHP5 and Apache on Ubuntu

How to install PHP5 and Apache on Ubuntu
In your command shell, you will run the following commands:

$ sudo apt-get install apache2

$ sudo apt-get install php5

$ sudo /etc/init.d/apache2 restart


Thats all. In case, you encountered an error like this “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName..” after restarting the Apache server. To fix that problem, you need to edit the httpd.conf file. Type this in your terminal:
$ sudo vi /etc/apache2/httpd.conf
By default httpd.conf file will be blank. Now, add the following line to the file. ServerName localhost
Save the file and restart the apache2 server
$ sudo /etc/init.d/apache2 restart
To make sure that everything is working fine, create a simple PHP code, save as phpinfo.php:

Then run it in your browser http://localhost/phpinfo.php, and it will display all PHP information.


Comments

Youve gotta hope that there’s someone for you
As strange as you are
Who can cope with the things that you do
Without trying too hard

– Jon Brion- Here we Go Via Quote Book:
Comments

Never allow someone to be your priority while allowing yourself to be their option.

– Mark Twain (via kari-shma) Via twentythree :
Comments

Never underestimate the power of destiny. Because when you least expect it, the littlest thing can cause a ripple effect that changes your life.

How I Met Your Mother Season 2 (via quote-book) Via Quote Book:
Comments

The greatest weakness of most humans is their hesitancy to tell others how much they love them while they’re alive.


Via Quote Book:
Comments

I’m here. I love you. I don’t care if you need to stay up crying all night long, I will stay with you. There’s nothing you can ever do to lose my love. I will protect you until you die, and after your death I will still protect you. I am stronger than depression and I am braver than loneliness and nothing will ever exhaust me.

Elizabeth Gilbert (via kari-shma) Via twentythree :
Comments

I hope that someday, somebody wants to hold you for twenty minutes straight, and that’s all they do. They don’t pull away. They don’t look at your face, they don’t try to kiss you. All they do is wrap you up in their arms, without an ounce of selfishness in it.


Via twentythree :
Comments

In life you can never be too kind or too fair; everyone you meet is carrying a heavy load. When you go through your day expressing kindness and courtesy to all you meet, you leave behind a feeling of warmth and good cheer, and you help alleviate the burdens everyone is struggling with.

Brian Tracy  Via twentythree :
Comments

I’d rather have a moment of wonderful than a lifetime of nothing special.

Steel Magnolias Via twentythree :
Comments

A friend will know by the sound of your voice, by the look on your face, by the way you walk, by the things you do, exactly what kind of day you’re having.

Unknown (via kari-shma) Via twentythree :
Comments

Find a guy who calls you beautiful instead of hot, who calls you back when you hang up on him, who will lie under the stars and listen to your heartbeat, or will stay awake just to watch you sleep… wait for the boy who kisses your forehead, who wants to show you off to the world when you are in sweats, who holds your hand in front of his friends, who thinks you’re just as pretty without makeup on. One who is constantly reminding you of how much he cares and how lucky he is to have you… The one who turns to his friends and says, ‘that’s her.

– Unknown? (via kari-shma) Via twentythree :
Comments


Comments

It is only with the heart that one can see rightly; what is essential is invisible to the eye.

– Antoine de Saint Exupery | submitted by: girlwithoutwings (via quote-book) Via Quote Book:
Comments
110
To Tumblr, Love Metalab