茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    PHP處理SQL腳本文件導(dǎo)入到MySQL的代碼實(shí)例
    來源:易賢網(wǎng) 閱讀:1055 次 日期:2014-08-22 11:08:05
    溫馨提示:易賢網(wǎng)小編為您整理了“PHP處理SQL腳本文件導(dǎo)入到MySQL的代碼實(shí)例”,方便廣大網(wǎng)友查閱!

    通常在制作安裝程式,數(shù)據(jù)備份程序的時(shí)候會(huì)要用到這樣的代碼,我看網(wǎng)上有是有不太多,而且有些也不是很好用,有時(shí)候這種代碼直接用現(xiàn)成的可以節(jié)省很多時(shí)間,那么我就從stackoverflow轉(zhuǎn)了一個(gè)過來,需要的朋友可以參考下

    代碼如下:<?php

    // Name of the file

    $filename = 'churc.sql';

    // MySQL host

    $mysql_host = 'localhost';

    // MySQL username

    $mysql_username = 'root';

    // MySQL password

    $mysql_password = '';

    // Database name

    $mysql_database = 'dump';

    // Connect to MySQL server

    mysql_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error());

    // Select database

    mysql_select_db($mysql_database) or die('Error selecting MySQL database: ' . mysql_error());

    // Temporary variable, used to store current query

    $templine = '';

    // Read in entire file

    $lines = file($filename);

    // Loop through each line

    foreach ($lines as $line)

    {

    // Skip it if it's a comment

    if (substr($line, 0, 2) == '--' || $line == '')

    continue;

    // Add this line to the current segment

    $templine .= $line;

    // If it has a semicolon at the end, it's the end of the query

    if (substr(trim($line), -1, 1) == ';')

    {

    // Perform the query

    mysql_query($templine) or print('Error performing query '<strong>' . $templine . '': ' . mysql_error() . '<br /><br />');

    // Reset temp variable to empty

    $templine = '';

    }

    }

    echo "Tables imported successfully";

    ?>

    更多信息請(qǐng)查看IT技術(shù)專欄

    更多信息請(qǐng)查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機(jī)網(wǎng)站地址:PHP處理SQL腳本文件導(dǎo)入到MySQL的代碼實(shí)例
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026上岸·考公考編培訓(xùn)報(bào)班

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)