Giter Club home page Giter Club logo

phpsql's Introduction

phpSQL

Latest Stable Version Total Downloads License PHP Version Require

MySql İçin Bir Php Kütüphanesi

Herhangi Bir Sorun Olursa Buradan Ulaşabilirsiniz Ayrıca Dosyada Php Documentor Kullanılmaktadır, Modern Editörlerde İşinize Yarayabilir (Sıkıştırılmış Dosya İçin Geçerli Değildir!)

Kurulum

İlk Önce Dosyamızı Dahil Edelim

// Dosya İle
require __DIR__."/phpsql.class.php";
// Composer İle
require __DIR__."/vendor/autoload.php";

Composer Kullanıyorsanız Bu Komutu CMD'ye Yazmayı Unutmayın !

composer require gamerboytr/phpsql

Sınıfımızı Başlatalım

$phpsql = new GamerboyTR\phpSQL();

Eğerki MySQL Ayarlarınız(kullanıcı adı, şifre vs.) Farklıysa Bunu Ayarlayabiliriz

$phpsql = new GamerboyTR\phpSQL("host", "kullanici_adi", "sifre");
// Veya
$phpsql->set_config("host", "kullanici_adi", "sifre");

Komutlar

Hadi Bir Veritabanına Bağlanalım !

$phpsql->set_db("veritabani_adi");

Veritabanından Veri Çekelim

$veri = $phpsql->select("seçici", "tablo");
// Örnek
$veri = $phpsql->select("*", "üyeler");

Veritabanında Sorgu(query) Çalıştıralım

$veri = $phpsql->query("sorgu");
// Örnek
$veri = $phpsql->query("SELECT * FROM üyeler");

Sınıfın Kaydettiği MySql Bilgilerini Alalım

$dize = $phpsql->get_config(); // Bir Array Döndürür

Kolay Bir Şekilde MySql Sınıfını Alalım

// phpSQL ile
$mysqli = $phpsql->connect();
// phpSQL olmadan
try {
    @$mysqli = new mysqli("host", "kullanici_adi", "şifre", "veritabanı");
    if($mysqli->connect_errno)
        die("<br>Mysqli Bağlanma Hatası : ".$mysqli->connect_error);
} catch (\Throwable $th) {
    die("<br>Mysqli Bağlanma Hatası : $th");
}

Tablo İşlemleri

Tablo Oluşturma

Alabileceği Değerler

  • length - Satırın Uzunluğu / int
  • AI (AUTO_INCREMENT) - Otomatik Artış / boolean
  • unique - Ekstra Olarak (PRIMARY_KEY gibi) / string|null
  • isnull - Boş mu / boolean
  • comment - Açıklama / string|null
$phpsql->create_table("tablo_adi", [
    [
        "name" => "satir_adi",
        "type" => "varchar"
    ]
]);

Tablodan Veri Silme

$phpsql->delete("tablo_adi", "seçici");
// Örnek
$phpsql->delete("kullanicilar", "adi='mehmet'");

Tabloları Listeleme

Eğerki Verdiğiniz Değer Boşsa Kütüphanede Tanımladığınız Veritabanını Kullanır

print_r($phpsql->get_tables("phpsql")); // Bir Array Döndürür

Tabloya Veri Ekleme

$phpsql->insert("tablo_adi", [
    "veri_adi" => "veri_degeri"
]);

Tablodaki Veriyi Güncelleme

$phpsql->update("tablo_adi", [
    "veri_adi" => "guncellencek_veri_degeri"
], "Nerede");
// Örnek
$phpsql->update("üyeler", [
    "yetki" => "admin"
], "kullanici_adi='gamerboytr'");

Veritabanı İşlemleri

Veritabanı Oluşturma

$phpsql->create_db("veritabani_adi");

Veritabanlarını Listeleme

$phpsql->get_dbs(); // Array Döndürür

Veritabanı Silme

$phpsql->drop("tablo_veya_veritabani_adi", "silinecek_tur");
// Örnek Veritabanı Silme
$phpsql->drop("phpsql", "database");
// Örnek Tablo Silme
$phpsql->drop("üyeler", "table");

Kütüphane Ayalarını Kaydetme/Yükleme

Dikkat Kaydedilen Ayarı Yükleyeceğiniz Zaman $phpsql Değişkenini Altına Ayarlamayı Unutmayın !

// Örnek
$phpsql = new GamerboyTR\phpSQL();
$phpsql->restore_config();

Kaydetme

Alabileceği Değerler

  • fileSavePath - Dosyayı Kaydedeceği Klasör (Boş Veya "./" İse O Dizine Kaydedilir) / string
  • overwriteFile - Klasörde Zaten Kaydedilmiş Bir Yapılandırma Ayarı Varsa Üzerine Yaz / boolean
$phpsql->save_config([
    // Değerler Buraya
]);

Yükleme

$phpsql->restore_config("klasor");

Author : GamerboyTR Mail : [email protected] Web : https://www.gamerboytr.ml

phpsql's People

Contributors

xielqs avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.