Created
August 29, 2016 13:03
-
-
Save kevsersrca/d61cc0d77972d9829669768d057f15ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connect | |
////////////// Veritabanına bağlanmayı sağlayan sorgu //// | |
try{ | |
$db= new PDO("mysql:host=localhost;dbname=veritabani_adi","kullanici_adi","sifre"); | |
} | |
catch (PDOexception $e){ | |
print $e->getMessage(); | |
} | |
$yazi = $db->prepare('insert into yazilar_tablosu (baslik,aciklama) values(?,?)'); | |
$yazi->execute(array($baslik,$aciklama)); | |
if($yazi){ | |
echo "Kategori Eklendi"; | |
} | |
else { | |
echo ' Kategori eklenemedi '; | |
} | |
insert | |
$yazi = $db->prepare('insert into yazilar_tablosu (baslik,aciklama) values(?,?)'); | |
$yazi->execute(array($baslik,$aciklama)); | |
if($yazi){ | |
echo "Kategori Eklendi"; | |
} | |
else { | |
echo ' Kategori eklenemedi '; | |
} | |
listeleme | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
if($user_bul = $db->query('SELECT * FROM kullanicilar WHERE id=3 ')){ | |
foreach($db->query('SELECT * FROM kullanicilar WHERE id=3 ') as $user_bilgileri) { | |
// id si 3 olan kullanıcının veri tabanında var olan kullanici_adi alanından kullanıcı adını listeledik | |
echo $user_bilgileri["kullanici_adi"]; | |
} | |
update | |
$guncelle = $db->prepare("UPDATE kullanici_bilgileri SET ad=?,soyad=?,eposta=?,yas=? WHERE id = ?"); | |
$guncelle->execute(array($ad, $soyad, $eposta, $yas, $gelenid)); | |
if($guncelle) { | |
echo "güncelleme işlemi başarılı"; | |
} | |
delete | |
if($count = $db->exec('DELETE FROM kullanici_bilgileri WHERE id = 3 ')){ | |
// kullanıcı id si 3 olan kullanıcıyı sil dedik | |
echo $count . ' Kullanıcı silindi'; | |
} | |
else { echo "silinemedi";} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment