PHP MsSQL(MS SQL 2012 express)自製資料庫還原程式(可以指定CSV將資料變成TABLE的內容)
PHP MsSQL(MS SQL 2012 express)自製資料庫還原程式(可以指定CSV將資料變成TABLE的內容)
php、MsSQL、MSSQL、express、header、odbc_connect、isset、fopen、odbc_num_fields、odbc_field_name、fwrite、fclose、odbc_close、odbc_free_result、trim、odbc_result
| <?php     //http://www.programgo.com/article/48613569901/;jsessionid=85BFB10EFD4F2C1C7F7EC17649DB14B4   /**   *   *   *   */     header(“Content-Type:text/html;   //數據庫配置信息   $user=$_GET[‘user’];   $pw=$_GET[‘pw’];   $dbname=$_GET[‘dbname’];   $tbname=$_GET[‘tbname’];   set_time_limit(3600);//1hr   if(!isset($user)   {      die(‘參數不足,無法執行‘);   }      $server=’127.0.0.1′;   /*   $username=’root’;     $password=’700502′;     $database=’v78′;     */   $connstr   $connect   $sql   $result[0]   if   {      die(‘無法執行清空資料表‘);   }   $filename   if(file_exists($filename))   {      $file      $index=0;            while      {        $str        if($str!=”)//因為換行符號也算一行,所以雖然只有兩行資料,但是會有三行數據        {           if($index==0)           {             $field_name=trim($str,”\n”);//取出欄位名稱並且刪除‘\n’           }           else           {             $sql=”INSERT             echo             echo             $result[$index]           }        }        $index++;      }      fclose($file);      }   else   {      die(‘還原檔案不存在‘);   }    odbc_close($connect);   echo ?>  |