In this article I discuss the two MySQL built-in connection functions "mysql_Connect()" and "mysql_Pconnect()" in PHP. Suppose you want to insert some data into the emp detail table of your database in a PHP application. The first thing that must be done is to create a connection for the table data for the operations and that is done using mysql_connect(), because before you can access data in a database, you must create a connection to the database and after performing all the operations on the database, you should close the connection using the mysql_close() function, but a Pconnection is already open and available for use at any time; the mysql_pconnect() function will not be closed and will persist for future use.
Syntax
Mysql_connect('localhost');
|
<?php
//use for connection
{
$con= mysql_connect("localhost","my_user","my_password","my_db");
echo "$con";
}
?>
Output
Mysql_pconnect('localhost');
|
The
Pconnect function uses minimal resources because the mysql_pconnect()
function is already connected with your database connection; it does
need to have a connection established with the database every time the
page is loaded, for when you want to persistent a connection.
When you want a connection then you first find a persistent connection link that is already open with the same host, username and password. The persistent connection is made with a max connection and connected with max clients. This connection is a multi-credential connection.
ExampleWhen you want a connection then you first find a persistent connection link that is already open with the same host, username and password. The persistent connection is made with a max connection and connected with max clients. This connection is a multi-credential connection.
<?php
//use for persistence connection
$conn = mysql_pconnect("localhost","my_user","my_password","my_db");
echo $conn;
?>
Output
Do this hack to drop 2lb of fat in 8 hours
ReplyDeleteMore than 160k men and women are utilizing a easy and secret "liquids hack" to burn 2lbs each and every night in their sleep.
It's scientific and works with anybody.
Here's how to do it yourself:
1) Grab a drinking glass and fill it up with water half full
2) Proceed to learn this awesome HACK
so you'll become 2lbs lighter in the morning!