Tuesday, February 7, 2012

Database class has been Modified in PHP

class Database
{
public $con;
//by default the system will identify them with var keyword.
var $db;
//these variables you can call any number of times with class objects.
var $die;

function set_db()
//the function will be started here.
{
//make connection to be available for script.
$this->con = mysql_connect("localhost","root","");
if (!$this->con)
  {
  die('Could not connect: ' . mysql_error());
  }
//introduce the db to script.
$this->db = mysql_select_db("idm1", $this->con);

}

function get_db()
//start function to pass results to script.
{
return $this->con;
return $this->db;
}

function close_con()
//provide the close feature to be used by script.
{
$this->die = mysql_close($this->con);
return $this->die();
}
//end of class.
}

Without no argument, The database class will be implemented here to provide the infrastructure for any no of php script.


No comments:

Post a Comment