Created
August 23, 2017 07:26
-
-
Save senocak/8b452edee32b66722460f8a654bc8035 to your computer and use it in GitHub Desktop.
PDO and verot.net class upload update
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
public function duzenle($sutun,$deger,$tablo,$resim,$dizin,$id,$en,$boy){ | |
if($sutun!=""){ | |
$tablo_degerleri=explode("--",$deger); | |
$tablo_adlari=explode("--",$sutun); | |
$tablo_degerleri_text=""; | |
for($i=0;$i<count($tablo_adlari);$i++){ | |
$tablo_degerleri_text=$tablo_adlari[$i]."=:".$tablo_adlari[$i].",".$tablo_degerleri_text; | |
} | |
}else{ | |
$tablo_degerleri_text=""; | |
} | |
$tablo_degerleri_text = rtrim($tablo_degerleri_text, ","); | |
if($tablo=="ayarlar"){ | |
$resim_tablo="logo"; | |
}else{ | |
$resim_tablo="resim"; | |
} | |
$eski_resim=""; | |
$query = $this->db->query("SELECT * FROM $tablo where id='$id'")->fetch(PDO::FETCH_ASSOC); | |
if ($query){ | |
$eski_resim=$query["$resim_tablo"]; | |
} | |
if($resim["name"]){ | |
if($dizin!=""){ | |
$dizin="/".$dizin; | |
} | |
if($sutun!=""){ | |
$tablo_degerleri_text=$tablo_degerleri_text.",$resim_tablo=:".$resim_tablo; | |
}else{ | |
$tablo_degerleri_text=$tablo_degerleri_text." $resim_tablo=:".$resim_tablo; | |
} | |
$tablo_degerleri_text="UPDATE $tablo SET ".$tablo_degerleri_text." where id=:id"; | |
require_once ('class.upload.php'); | |
$yukle = new upload($resim); | |
$klasor = '../images'.$dizin; | |
if ($yukle->uploaded){ | |
$yukle->image_resize = true; | |
$yukle->image_ratio_fill = true; | |
$yukle->image_x = $en; | |
$yukle->image_y = $boy; | |
$yukle->file_new_name_body =$tablo."_".rand(1000,9999); | |
$yukle->process($klasor); | |
if($yukle->processed) { | |
if($eski_resim!=""){ | |
unlink($klasor."/".$eski_resim); | |
} | |
$stmt = $this->db->prepare($tablo_degerleri_text); | |
for($i=0;$i<count($tablo_degerleri);$i++){ | |
$stmt->bindParam(':'.$tablo_adlari[$i], $tablo_degerleri[$i], PDO::PARAM_STR); | |
} | |
$stmt->bindParam(':'.$resim_tablo, $yukle->file_dst_name, PDO::PARAM_STR); | |
$stmt->bindParam(':id', $id, PDO::PARAM_STR); | |
$insert =$stmt->execute(); | |
if ($insert){ | |
echo '<script>alert("Güncelleme Başarılı.");</script>'; | |
} | |
}else{ | |
echo '<script>alert("Güncelleme Başarısız.'.$yukle->error().'");</script>'; | |
} | |
echo "<script language='javascript'>location.href='index.php?sayfa=$tablo';</script>"; | |
} | |
}else{ | |
$tablo_degerleri_text="UPDATE $tablo SET ".$tablo_degerleri_text." where id=:id"; | |
//echo $tablo_degerleri_text."<br><br>"; | |
$stmt = $this->db->prepare($tablo_degerleri_text); | |
for($i=0;$i<count($tablo_degerleri);$i++){ | |
$stmt->bindParam(':'.$tablo_adlari[$i], $tablo_degerleri[$i], PDO::PARAM_STR); | |
$stmt->bindParam(':id', $id, PDO::PARAM_STR); | |
//echo ':'.$tablo_adlari[$i]."=>".$tablo_degerleri[$i]."<hr>"; | |
} | |
$insert =$stmt->execute(); | |
if ($insert){ | |
echo '<script>alert("Güncelleme Başarılı.");</script>'; | |
echo "<script language='javascript'>location.href='index.php?sayfa=".$tablo."&duzenle=$id';</script>"; | |
} | |
} | |
} |
Author
senocak
commented
Aug 23, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment