<?php
class Mysql{
var $db;
var $host;
var $user;
var $password;
var $database;
var $query;
var $result;
var $row;
var $dataSet;
var $numRows;
function Mysql($host="localhost",$user="root",$password="",$database="komputerbelajar"){
$this->host=$host;
$this->user=$user;
$this->password=$password;
$this->database=$database;
}
function connect(){
$this->db=mysql_connect($this->host,$this->user,$this->password);
mysql_select_db($this->database,$this->db);
}
function execute($query){
$this->query=$query;
if($this->result=mysql_query($query,$this->db)){
return true;
} else {
return false;
}
}
function getDataSet(){
$dataSet=array();
$i=0;
while($r=mysql_fetch_row($this->result)){
$field=0;
for($field=0;$fieldresult);$field++){
$dataSet[$i][$field]=$r[$field];
}
$i++;
}
return $dataSet;
}
function getNumRows(){
$this->numRows=mysql_num_rows($this->result);
return $this->numRows;
}
function closeConnection(){
mysql_close($this->db);
}
}
?>
atau silahkan download di sini
No comments:
Post a Comment