
<?php
include("class_seting.php");
include("class_support.php");
class mysql{
	var $koneksi;
	var $query = array();
	
	function mysql(){
		$seting = new seting();
		$this->myServer = $seting->Server;
		$this->myUser = $seting->User;
		$this->myPass = $seting->Pass;
		$this->myDB = $seting->DB;
		$this->cek_query = "off";
		$this->koneksi = @mysql_connect($this->myServer, $this->myUser, $this->myPass) or die("Koneksi dengan database terputus");
		$support = new support();
		$this->support = $support;
	}
	function select_db(){
		$d = mysql_select_db($this->myDB, $this->koneksi) or die ("database ".$this->myDB." tidak ditemukan");
	}	
	function execute($sql,$type){
		$this->select_db();	
		$query = @mysql_query($sql,$this->koneksi); 
		//echo $sql."<br><br>";
		//die($sql);	
		if($type == 'jumlah') return mysql_num_rows($query);
		else if($type == 'order') return mysql_fetch_assoc($query);
		else return $query;
	}
	function sql_order_count($sql){
		$count_array = 1;
		$query =  $this->execute($sql,'');
		$this->cek_query = "on";
		 while($a = mysql_fetch_array($query)){
		 	$this->data[$count_array] = $a;
			$count_array++;				
		}
		return $this->execute($sql,'jumlah');
	}	
	function sql_order_count2($sql,$a){
		$begin = $a;
		$end = $a + 20;
		$count_array = 1;
		$query =  $this->execute($sql,'');
		$this->cek_query = "on";		
		$query_arr = mysql_fetch_array($query);
		for($b=$begin;$b<=$end;$b++){			
			$this->data[$b] = $query_arr[$b];
		}
		return $this->execute($sql,'jumlah');
	}	
	function sql_order_seek($sql,$kolom,$count){
		$data = str_replace('"',"&quot;",trim($this->data[$count][$kolom]));
		$data = str_replace("'","&quot;",trim($this->data[$count][$kolom]));
		//$data = str_replace("''","",trim($this->data[$count][$kolom]));
		return $data;
	}	
	function show_sql($stat){
		echo $this->current_sql."--<br>";
		if($stat == "1") die();
	}
}

?>
