/*class lingkaran {
var $jari_jari;
var $diameter;
var $luas;
var $keliling;
function hitung_lingkaran($r)
{
$this->jari_jari=$r;
$this->luas = 3.14*($r*$r);
$this->diameter=2*$r;
$this->keliling=2*3.14*$r;
}
}
$luas_lingkaran = new lingkaran;
$luas_lingkaran->hitung_lingkaran(3);
echo "jari-jari lingkaran : $luas_lingkaran->jari_jari
";
echo "keliling lingkaran : $luas_lingkaran->keliling";
*/
/* db.class.php
A simple database manipulation class by Salman AS, salmanas@programmer.net.
ChangeLog: 02/14/2001 Started.
02/26/2001 Query Method added.
*/class DB {
var $Connection;
var $DBHost=”localhost”;
var $DBUser=”root”;
var $DBPass=”";
var $DBName;
var $DBRecSet;
// Constructor for this class
function DB ($db_host, $db_user, $db_pass, $db_name) {
$this->DBHost = $db_host;
$this->DBUser = $db_user;
$this->DBPass = $db_pass;
$this->DBName = $db_name;
if (!$this->Open()) echo “Error occure on openning connection or database. Period.”;
}
// Open database server connection
function Open () {
if (!($ServerConn = @mysql_pconnect($this->DBHost, $this->DBUser, $this->DBPass))) {
return 0;
} else {
if (!($this->Connection = @mysql_select_db($this->DBName, $ServerConn)))
return 0;
else
return 1;
}
}
function Query ($sql) {
if (empty($sql)) echo “No SQL command given. Period.”;
if ($this->DBRecSet=@mysql_query(addslashes($sql)))
return $this->DBRecSet;
else
return 0;
}
}
?>
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar