TGViewer
star source • استار سورس star source • استار سورس @star_sourcee · 26.5K subscribers
Post #713 1.7K
#تیکه_کد گرفتن بکاپ از دیتابیس mysql با php 🗂

<?php
$connection = mysqli_connect('localhost','user','pass','quiz');
$tables = array();
$result = mysqli_query($connection,"SHOW TABLES");
while($row = mysqli_fetch_row($result)){
  $tables[] = $row[0];
}
$return = '';
foreach($tables as $table){
  $result = mysqli_query($connection,"SELECT * FROM ".$table);
  $num_fields = mysqli_num_fields($result);
   
  $return .= 'DROP TABLE '.$table.';';
  $row2 = mysqli_fetch_row(mysqli_query($connection,"SHOW CREATE TABLE ".$table));
  $return .= "\n\n".$row2[1].";\n\n";
   
  for($i=0;$i<$num_fields;$i++){
    while($row = mysqli_fetch_row($result)){
      $return .= "INSERT INTO ".$table." VALUES(";
      for($j=0;$j<$num_fields;$j++){
        $row[$j] = addslashes($row[$j]);
        if(isset($row[$j])){ $return .= '"'.$row[$j].'"';}
        else{ $return .= '""';}
        if($j<$num_fields-1){ $return .= ',';}
      }
      $return .= ");\n";
    }
  }
  $return .= "\n\n\n";
}
//save file
$handle = fopen("backup.sql","w+");
fwrite($handle,$return);
fclose($handle);
echo "Successfully backed up";
?>

سیستم سریع و ساده پشتیبان گیری پایگاه داده Mysql توسط php .
Channel : @Star_sourcee
More from @star_sourcee
  1. Oct 6, 2026⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐ بخاطر احتمال جنگ و اعتراضات و در پیِ اون، ملی‌شدن اینترنت، یه سری کانال پولی پی…
  2. Oct 6, 2026انگلیسی با کوئیز 🔹JOIN پادکست و کتاب صوتی رایگان 🔸JOIN خدمات دانشجویی سفارش ودریافت پروژ…
  3. Aug 4, 2026📑 | سورس ربات ویروس توتال | ربات شناسایی فایل های مخرب 🔐 | ورژن : 3 💻 | زبان : PHP 8+ �…
  4. May 28, 2026سه ماه، مدت زمان کمی نیست!
  5. May 26, 2026&rlm;شمارش معکوس برای حذف سوپراپلیکیشنای ایرانی... ⏳️
  6. May 26, 2026بالاخره بعد از ٣ ماه قطعی گسترده، روند اتصال اینترنت رسماً شروع شده و داره خیلی خوب پیش می…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →