عرض مشاركة واحدة
احصائياتى

الردود
8

المشاهدات
1085
Mohamed yasser
مشرف قسم تطوير المواقع
.:: مطور لغة PHP ::.
  • Mohamed yasser is just really niceMohamed yasser is just really niceMohamed yasser is just really niceMohamed yasser is just really nice

  • Mohamed yasser غير متواجد حالياً

المشاركات
589

+التقييم
76

تاريخ التسجيل
Mar 2019

الاقامة
ام الدنيا مصر

نظام التشغيل
Other

رقم العضوية
1982
05-21-2019, 03:37 AM
المشاركة 1
05-21-2019, 03:37 AM
المشاركة 1
افتراضي كود عمل back up للقاعده

السلام عليكم ورحمة الله وبركاته
كود عمل عملية حفظ لقاعده البيانات
كود PHP:
<?php
    
$connection 
mysqli_connect('localhot','root','12345678','Hazem');
$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
$date_base date('Y-m-d h.i.s');
$file_name'save_date/'.$date_base.'.sql';
$handle fopen("$file_name","w+");
fwrite($handle,$return);
fclose($handle);
$save_su_date 'Successfully backed up';


?>
مع تغير اسم Hazem باسم القاعده الي عايزه تحفظه
وكلمة سر بتاعت القاعده


التعديل الأخير تم بواسطة Mohamed yasser ; 05-23-2019 الساعة 11:25 PM