<?php class sorguCikarici{ private $dosyaAdi; private $icerik; public $sqlSorgulari; public function __construct($dosyaYeri = ''){ if(strlen($dosyaYeri) < 1){ $this->dosyaAdi = ''; }else{ $this->dosyaAdi = $dosyaYeri; } } public function sorgulariCikart(){ $sql=file($this->dosyaAdi); foreach($sql as $s){ $ek=substr($s, 0, 2); if(($ek != "--" and $ek != "/*") AND $s != "\n"){ $this->icerik.=$s; } } $this->icerik=trim(preg_replace('/\s\s+/', ' ', $this->icerik)); $this->icerik = preg_replace('~[\r\n]+~', '', $this->icerik); file_put_contents($this->dosyaAdi,$this->icerik); return $this->icerik; } } $sc = new sorguCikarici(dirname(__FILE__)."/data.sql"); $sc->sorgulariCikart(); ?>
Örnek data.sql
-- phpMyAdmin SQL Dump -- version 4.1.4 -- http://www.phpmyadmin.net -- -- Anamakine: 127.0.0.1 -- Üretim Zamanı: 02 Haz 2018, 00:41:47 -- Sunucu sürümü: 5.6.15-log -- PHP Sürümü: 5.4.24 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Veritabanı: `destek` -- -- -------------------------------------------------------- -- -- Tablo için tablo yapısı `mesajlar` -- CREATE TABLE IF NOT EXISTS `mesajlar` ( `mno` int(10) unsigned NOT NULL AUTO_INCREMENT, `kim` int(11) DEFAULT NULL, `zaman` datetime DEFAULT NULL, `ticketid` int(60) DEFAULT NULL, `mesaj` text CHARACTER SET latin5 NOT NULL, `y` int(1) NOT NULL DEFAULT '0', PRIMARY KEY (`mno`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Tablo için tablo yapısı `urunler` -- CREATE TABLE IF NOT EXISTS `urunler` ( `uno` int(10) unsigned NOT NULL AUTO_INCREMENT, `urun_adi` text CHARACTER SET latin5, `urun_fiyat` int(4) DEFAULT NULL, `urun_kimin` int(4) DEFAULT NULL, `urun_durumu` int(11) DEFAULT '0', `urun_bilgisi` text CHARACTER SET latin5, `urun_aciklama` text CHARACTER SET latin5, `urun_bitistarihi` date DEFAULT NULL, `urun_odemedurumu` int(1) NOT NULL DEFAULT '1', `urun_sipariszamani` datetime NOT NULL, `urun_alistarihi` date DEFAULT NULL, PRIMARY KEY (`uno`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Tablo için tablo yapısı `uyeler` -- CREATE TABLE IF NOT EXISTS `uyeler` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `kadi` varchar(15) DEFAULT NULL, `tel` varchar(11) DEFAULT NULL, `sifre` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Tablo döküm verisi `uyeler` -- INSERT INTO `uyeler` (`id`, `kadi`, `tel`, `sifre`) VALUES (1, 'admin', '5420', '14e1b6'); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Çıktısı data.sql
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";SET time_zone = "+00:00";CREATE TABLE IF NOT EXISTS `mesajlar` ( `mno` int(10) unsigned NOT NULL AUTO_INCREMENT, `kim` int(11) DEFAULT NULL, `zaman` datetime DEFAULT NULL, `ticketid` int(60) DEFAULT NULL, `mesaj` text CHARACTER SET latin5 NOT NULL, `y` int(1) NOT NULL DEFAULT '0', PRIMARY KEY (`mno`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;CREATE TABLE IF NOT EXISTS `urunler` ( `uno` int(10) unsigned NOT NULL AUTO_INCREMENT, `urun_adi` text CHARACTER SET latin5, `urun_fiyat` int(4) DEFAULT NULL, `urun_kimin` int(4) DEFAULT NULL, `urun_durumu` int(11) DEFAULT '0', `urun_bilgisi` text CHARACTER SET latin5, `urun_aciklama` text CHARACTER SET latin5, `urun_bitistarihi` date DEFAULT NULL, `urun_odemedurumu` int(1) NOT NULL DEFAULT '1', `urun_sipariszamani` datetime NOT NULL, `urun_alistarihi` date DEFAULT NULL, PRIMARY KEY (`uno`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;CREATE TABLE IF NOT EXISTS `uyeler` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `kadi` varchar(15) DEFAULT NULL, `tel` varchar(11) DEFAULT NULL, `sifre` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;INSERT INTO `uyeler` (`id`, `kadi`, `tel`, `sifre`) VALUES(1, 'admin', '5420', '14e1b6');