Advertisement
Derpost

Untitled

Jan 19th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.03 KB | None | 0 0
  1. <?php
  2. require_once 'connect.class.php';
  3.  
  4. class Get extends Connect {
  5.     private $sql = false;
  6.     private $baglan;
  7.     private $hatalar = array();
  8.     private $query;
  9.     private $count = false;
  10.     public  $data = array();
  11.  
  12.     function __construct() {
  13.         /*
  14.          * Yalnızca kısaltma..
  15.          */
  16.         $this->baglan = parent::BaglanDB();
  17.     }
  18.  
  19.     public function getSql($sql)
  20.     {
  21.         /*
  22.          *  GET SQL
  23.          *  String
  24.          */
  25.         if ($this->sql!==false)
  26.         {
  27.             unset($this->sql);
  28.         }
  29.         $this->sql = $sql;
  30.         return $sql;
  31.     }
  32.  
  33.     private function Query()
  34.     {
  35.         /*
  36.          * Sorguyu çalıştırır hata varsa
  37.          * hatayı döndürür
  38.          */
  39.         $this->query = mysql_query($this->sql,$this->baglan) or $error = mysql_error();
  40.         if(!empty($error))
  41.         {
  42.             $this->hatalar[] = mysql_error();
  43.             return mysql_error();
  44.         }
  45.         return $this->query;
  46.     }
  47.  
  48.     public function getData()
  49.     {
  50.         /*
  51.          * Veriyi çek
  52.          */
  53.         $this->Query();
  54.         $query = $this->query;
  55.         while ($row = mysql_fetch_assoc($query)) {
  56.             $this->data[] = $row;
  57.             $this->count = $this->count++;
  58.         }
  59.         return $this->data;
  60.     }
  61.  
  62.  
  63.     public function returnError()
  64.     {
  65.         /*
  66.          * Hata varsa bildir
  67.          */
  68.         if(!empty($this->hatalar))
  69.         {
  70.             foreach($this->hatalar as $hatalar)
  71.             {
  72.                 echo $hatalar . "<br/>";
  73.             }
  74.         }
  75.         else
  76.         {
  77.             echo 'Herhangi bir hata ile karşılaşılmadı';
  78.         }
  79.         return true;
  80.     }
  81.  
  82.     public function returnCount()
  83.     {
  84.          /*
  85.          * Kaç tane satır
  86.          * çekildi
  87.          */
  88.         if($this->count === false or $this->count==0)
  89.         {
  90.             return 0;
  91.             return "Herhangi bir veri bulunamadı..";
  92.         }
  93.         return $this->count;
  94.     }
  95. }
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement