Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ##
- ### Veritabanı Sınıfı // PHP Code:
- ##
- // Eğer sabit tanımlanmadıysa:
- //if(!defined('SMT_ERISIM')) { Erisim::HATA(); }
- class vt
- {
- public $user="root";
- public $pass="123456";
- private $host="localhost";
- private $db_s="test";
- public function ac()
- {
- @mysql_connect($this->host,$this->user,$this->pass) OR Die("<b>Hata bilgisi: </b>". mysql_error());
- }
- ####
- # SQL injection(bahar) temizliği yapar :)
- ####
- public function temizle($saf_sql)
- {
- return htmlentities($saf_sql);
- }
- ####
- # Sorgu yapar ve sonucları döndürür:
- ####
- public function sor_sonuc_al( $sql='', $tekil=TRUE, $tehlike=FALSE )
- {
- if( $tehlike===TRUE )
- {
- $sql = temizle($sql);
- }
- $snc = @mysql_query($sql);
- if( $tekil===TRUE )
- {
- return sonuc($snc); // Tek satır veri yolla
- }else{
- return sonuclar($snc); // Çok satırlı veri yolla
- }
- }
- ####
- # sor_sonuc_al() fonksiyonu içinde tekil veri aktarır:
- ####
- private function sonuc($sonuc)
- {
- return @mysql_fetch_row($sonuc);
- }
- ####
- # sor_sonuc_al() fonksiyonu içinde çoğul veri aktarır:
- ####
- private function sonuclar($sonuc)
- {
- return @mysql_fetch_array($sonuc);
- }
- ####
- # Satır sayısını verir:
- ####
- public function sonuc_sayısı($sonuc)
- {
- return mysql_affected_rows($sonuc);
- }
- ####
- # Hata oluşması durumunda:
- ####
- public function hata()
- {
- }
- public function kapa()
- {
- mysql_close();
- }
- }
- $v=new vt();
- $v->ac();
- // sorgu( $sql, $tekil, $temizleme )
- $veriler = $v->sor_sonuc_al( "SELECT * FROM abonelik", FALSE );
- $v->kapa();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement