Saturday, September 11, 2010

DataBase Connection Class

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
* Description of conCls
*
*/
class conCls {
//put your code here
var $con = null;
function connectDB()
{
$this->con = mysql_connect('localhost', 'root', '') or die('MySQL Connectivity Error..!
Error No : '. mysql_errno(). '
Error : '. mysql_error());
mysql_select_db('dcwb', $this->con);
return $this->con;
}

function Query($query)
{
$result = mysql_query($query, $this->con) or die('MySQL Query Error..!
Query : ' . $query . '
Error No : ' . mysql_errno() . '
Error : ' . mysql_error());
return $result;
}
function closeDB()
{
mysql_close($this->con);
}
}

No comments:

Post a Comment