Sql Sorgu Kontrol Sınıfı

<?php
class sqlKontrol{
	var $id_alan;
	var $id_deger;
	function sec($tablo,$alan,$deger){
		$sorgu="SELECT * FROM $tablo WHERE ";
		for($c=count($alan);$c>0;$c--) {
			$id=$c-1;
			$sorgu.=" ".$alan[$id]."='".$deger[$id]."' ";
			if($c-1!=0){
				$sorgu.=" AND ";
			}
		}
		return $sorgu;
	}
	function guncelle($tablo,$alan,$deger){
		$sorgu="UPDATE $tablo SET ";
		for($c=count($alan);$c>0;$c--) {
			$id=$c-1;
			$sorgu.=" ".$alan[$id]."='".$deger[$id]."' ";
			if($c-1!=0){
				$sorgu.=" , ";
			}
		}
		$sorgu.=" WHERE $this->id_alan = '$this->id_deger'";
		return $sorgu;
	}
	function ekle($tablo,$alan,$deger){
		$sorgu="INSERT INTO $tablo SET ";
		for($c=count($alan);$c>0;$c--) {
			$id=$c-1;
			$sorgu.=" ".$alan[$id]."='".$deger[$id]."' ";
			if($c-1!=0){
				$sorgu.=" , ";
			}
		}
		return $sorgu;
	}
	function sil($tablo,$alan,$deger){
		$sorgu="DELETE FROM $tablo WHERE ";
		for($c=count($alan);$c>0;$c--) {
			$id=$c-1;
			$sorgu.=" ".$alan[$id]."='".$deger[$id]."' ";
			if($c-1!=0){
				$sorgu.=" AND ";
			}
		}
		return $sorgu;
	}
} 
$data = new sqlKontrol;
echo $data->sec('table',['name1','name2'],['value1','value2']);
echo "<br>";
$data->id_alan="id";
$data->id_deger="1";
echo $data->guncelle('table',['name1','name2'],['value1','value2']);
echo "<br>";
echo $data->ekle('table',['name1','name2'],['value1','value2']);
echo "<br>";
echo $data->sil('table',['name1','name2'],['value1','value2']);
?>

Çıktısı

SELECT * FROM table WHERE name1='value1' 
SELECT * FROM table WHERE name2='value2' AND name1='value1' 
UPDATE table SET name2='value2' , name1='value1' WHERE id = '1'
INSERT INTO table SET name2='value2' , name1='value1' 
DELETE FROM table WHERE name2='value2' AND name1='value1'

 

Sizin Değerli Görüşlerinize İhtiyacımız Var.