Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. <?php
  2.  
  3. ##
  4. ### Veritabanı Sınıfı // PHP Code:
  5. ##
  6.  
  7. // Eğer sabit tanımlanmadıysa:
  8. //if(!defined('SMT_ERISIM')) { Erisim::HATA(); }
  9.  
  10. class vt
  11. {
  12.    
  13.     public $user="root";
  14.     public $pass="123456";
  15.     private $host="localhost";
  16.     private $db_s="test";
  17.    
  18.     public function ac()
  19.     {
  20.         @mysql_connect($this->host,$this->user,$this->pass) OR Die("<b>Hata bilgisi: </b>". mysql_error());
  21.     }
  22.    
  23.     ####
  24.     # SQL injection(bahar) temizliği yapar :)
  25.     ####
  26.    
  27.     public function temizle($saf_sql)
  28.     {
  29.         return htmlentities($saf_sql);
  30.     }
  31.    
  32.     ####
  33.     # Sorgu yapar ve sonucları döndürür:
  34.     ####
  35.    
  36.     public function sor_sonuc_al( $sql='', $tekil=TRUE, $tehlike=FALSE )
  37.     {
  38.         if( $tehlike===TRUE )
  39.         {
  40.             $sql = temizle($sql);
  41.         }
  42.        
  43.         $snc = @mysql_query($sql);
  44.        
  45.         if( $tekil===TRUE )
  46.         {
  47.             return sonuc($snc);    // Tek satır veri yolla
  48.         }else{
  49.             return sonuclar($snc); // Çok satırlı veri yolla
  50.         }
  51.     }
  52.    
  53.     ####
  54.     # sor_sonuc_al() fonksiyonu içinde tekil veri aktarır:
  55.     ####
  56.    
  57.     private function sonuc($sonuc)
  58.     {
  59.         return @mysql_fetch_row($sonuc);
  60.     }
  61.    
  62.     ####
  63.     # sor_sonuc_al() fonksiyonu içinde çoğul veri aktarır:
  64.     ####
  65.        
  66.     private function sonuclar($sonuc)
  67.     {
  68.         return @mysql_fetch_array($sonuc);
  69.     }
  70.    
  71.    
  72.     ####
  73.     # Satır sayısını verir:
  74.     ####
  75.     public function sonuc_sayısı($sonuc)
  76.     {
  77.         return mysql_affected_rows($sonuc);
  78.     }
  79.    
  80.     ####
  81.     # Hata oluşması durumunda:
  82.     ####
  83.     public function hata()
  84.     {
  85.        
  86.     }
  87.    
  88.     public function kapa()
  89.     {
  90.         mysql_close();
  91.     }
  92.    
  93. }
  94.  
  95. $v=new vt();
  96. $v->ac();
  97.  
  98. // sorgu( $sql, $tekil, $temizleme )
  99. $veriler = $v->sor_sonuc_al( "SELECT * FROM abonelik", FALSE );
  100.  
  101.  
  102.  
  103. $v->kapa();
  104. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement