搜索
首页后端开发php教程php mysql备份恢复分卷处理(数据库导入导出)_PHP教程

php mysql备份恢复分卷处理(数据库导入导出)_PHP教程

Jul 13, 2016 pm 05:06 PM
mysqlphp分卷处理备份导入导出恢复数据数据库

分卷处理就是把握们要处理的数据分成一个个小文件进行处理了,下面我来给大家介绍一个php mysql备份恢复分卷处理类,实现mysql数据库分卷备份,选择表进行备份,实现单个sql文件及分卷sql导入。

分卷导入类及思路详解

数据库导入导出是一个后台必要拥有的功能,网上一搜,有很多关于数据库导入导出的,但基本上一个大的系统,包含了许多我们并不需要的,而且他们都是自己的后台的形式,我并不喜欢的是拿人家的东西整合到自己的后台,我需要的是自己东西。于是参照了很多,自己写了一个关于分卷导入类。以方便调用。欢迎大家拍砖。

这里针对分卷文件是以‘_v1.sql’为结尾,实现单个sql文件及分卷sql导入,分卷导入可选择是否当前分卷导入余下分卷,我们只需要直接调用类即可完成

//分别是主机,用户名,密码,数据库名,数据库编码
$db = new DataManage ( 'localhost', 'root', 'root', 'test', 'utf8' );
//sql文件,是否只导入单个sql(即如果有其他分卷也不导入)
$db->restore ( './backup/20120516211738_all_v1.sql', false );对应如何去列出备份的sql文件或选择sql之类的,自己去实现,那个不在这个范畴了,也很简单的。

实际演示效果:


还有目前只实现了数据库导入,关于数据库导出的,正在编写功能。

下面是完整的类代码:(具体思路及实现代码里面都有说明,这里不在赘述)

 代码如下 复制代码

/**
 * @author yanue
 * @copyright Copyright (c) 2012 www.yanue.net
 * 说明:分卷文件是以_v1.sql为结尾
 * 功能:实现单个sql文件及分卷sql导入,分卷导入可选择是否当前分卷导入余下分卷
 * 使用方法:
 *
 *
 * ------------------------------------------------------------------
//分别是主机,用户名,密码,数据库名,数据库编码
$db = new DataManage ( 'localhost', 'root', 'root', 'test', 'utf8' );
//sql文件,是否只导入单个sql(即如果有其他分卷也不导入)
$db->restore ( './backup/20120516211738_all_v1.sql', false );
 *----------------------------------------------------------------------
 */
class DataManage {
 var $db; // 数据库连接
 var $database; // 所用数据库
 var $sqldir; // 数据库备份文件夹

 /**
  * 初始化
  *
  * @param string $host
  * @param string $username
  * @param string $password
  * @param string $database
  * @param string $charset
  */
 function __construct($host = 'localhost', $username = 'root', $password = '', $database = 'test', $charset = 'utf8') {
  $this->host = $host;
  $this->username = $username;
  $this->password = $password;
  $this->database = $database;
  $this->charset = $charset;
  // 连接数据库
  $this->db = mysql_connect ( $this->host, $this->username, $this->password ) or die ( "数据库连接失败." );
  // 选择使用哪个数据库
  mysql_select_db ( $this->database, $this->db ) or die ( "无法打开数据库" );
  // 数据库编码方式
  mysql_query ( 'SET NAMES ' . $this->charset, $this->db );
 }

 /**
  * 导入备份数据
  * 说明:分卷文件格式20120516211738_all_v1.sql
  *
  * @param string $sqlfile
  * @param bool $single
  */
 function restore($sqlfile, $single = FALSE) {
  // 检测文件是否存在
  if (! file_exists ( $sqlfile )) {
   exit ( "文件不存在!请检查" );
  }
  $this->lock ( $this->database );
  // 获取数据库存储位置
  $sqlpath = pathinfo ( $sqlfile );
  $this->sqldir = $sqlpath ['dirname'];
  // 检测是否包含分卷,将类似20120516211738_all_v1.sql从_v分开,有则说明有分卷
  $volume = explode ( "_v", $sqlfile );
  $volume_path = $volume [0];
  echo "请勿刷新及关闭浏览器以防止程序被中止,如有不慎!将导致数据库结构受损
";
  echo "正在导入备份数据,请稍等!
";
  if (empty ( $volume [1] ) || $single) {
   echo "正在导入sql:" . $sqlfile . '
';
   // 没有分卷
   if ($this->_import ( $sqlfile )) {
    echo "数据库导入成功!";
   } else {
    exit ( '数据库导入失败!' );
   }
  } else {
   // 存在分卷,则获取当前是第几分卷,循环执行余下分卷
   $volume_id = explode ( ".sq", $volume [1] );
   // 当前分卷为$volume_id
   $volume_id = intval ( $volume_id [0] );
   while ( $volume_id ) {
    $tmpfile = $volume_path . "_v" . $volume_id . ".sql";
    // 存在其他分卷,继续执行
    if (file_exists ( $tmpfile )) {
     // 执行导入方法
     echo "正在导入分卷$volume_id:" . $tmpfile . '
';
     if ($this->_import ( $tmpfile )) {

     } else {
      exit ( "导入分卷$volume_id:" . $tmpfile . '失败!可能是数据库结构已损坏!请尝试从分卷1开始导入' );
     }
    } else {
     echo "此分卷备份全部导入成功!
";
     return;
    }
    $volume_id ++;
   }
  }
 }

 /**
  * 将sql导入到数据库(普通导入)
  *
  * @param string $sqlfile
  * @return boolean
  */
 private function _import($sqlfile) {
  $name = basename ( $sqlfile );
  $sqls = file ( $sqlfile );
  foreach ( $sqls as $sql ) {
   str_replace ( "r", "", $sql );
   str_replace ( "n", "", $sql );
   if (! mysql_query ( trim ( $sql ), $this->db ))
    return false;
  }
  return true;
 }

 // 关闭数据库连接
 private function close() {
  mysql_close ( $this->db );
 }

 // 锁定数据库,以免备份或导入时出错
 private function lock($tablename, $op = "WRITE") {
  if (mysql_query ( "lock tables " . $tablename . " " . $op ))
   return true;
  else
   return false;
 }

 // 解锁
 private function unlock() {
  if (mysql_query ( "unlock tables" ))
   return true;
  else
   return false;
 }

 // 析构
 function __destruct() {
  mysql_query ( "unlock tables", $this->db );
  mysql_close ( $this->db );
 }
}

mysql备份恢复分卷处理,调用简单


分卷导入思路:按行读取sql文件,将每一行当作完整的sql语句存到数组再循环执行插入数据库就可以了,但是在创建表语句分了多行,这个需要单独处理(就这个花了我好长时间的);

(哇,感觉文章好长啊!主要是那个类文件给占用了)。

更新时间: 2012年10月6日
更新说明: 1.去除sql导入的时候排除sql文件里面的注释’– ‘ 从而解决sql中单双引号不能导入
2.单行读取后的sql直接执行,避免重新将sql语句组合到数组中再从数组中读取导入sql,提高效率

下载地址: https://github.com/yanue/Dbmanage

 代码如下 复制代码

导出后的sql文件格式如下:

--
-- MySQL database dump
-- Created by DBManage class, Power By yanue.
--
-- 主机: localhost
-- 生成日期: 2012 年  10 月 06 日 22:32
-- MySQL版本: 5.1.50-community
-- PHP 版本: 5.3.9-ZS5.6.0

--
-- 数据库: `test`
--

-- -------------------------------------------------------

--
-- 表的结构aa
--

DROP TABLE IF EXISTS `aa`;
CREATE TABLE `aa` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `content` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 aa
--

INSERT INTO `aa` VALUES('1','

我是测试数据 呵呵

');下面是类代码:

/**
 * @author yanue
 * @copyright  Copyright (c) 2012 yanue.net
 * @link  http://yanue.net/archives/174.html
 * @version 1.1
 * 创建时间: 2012年5月21日

更新时间: 2012年10月6日
更新说明: 1.去除sql导入的时候排除sql文件里面的注释'-- ' 从而解决sql中单双引号不能导入
2.单行读取后的sql直接执行,避免重新将sql语句组合到数组中再从数组中读取导入sql,提高效率

 * 说明:分卷文件是以_v1.sql为结尾(20120522021241_all_v1.sql)
 * 功能:实现mysql数据库分卷备份,选择表进行备份,实现单个sql文件及分卷sql导入
 * 使用方法:
 *
 * ------1. 数据库备份(导出)------------------------------------------------------------
//分别是主机,用户名,密码,数据库名,数据库编码
$db = new DBManage ( 'localhost', 'root', 'root', 'test', 'utf8' );
// 参数:备份哪个表(可选),备份目录(可选,默认为backup),分卷大小(可选,默认2000,即2M)
$db->backup ();
 * ------2. 数据库恢复(导入)------------------------------------------------------------
//分别是主机,用户名,密码,数据库名,数据库编码
$db = new DBManage ( 'localhost', 'root', 'root', 'test', 'utf8' );
//参数:sql文件
$db->restore ( './backup/20120516211738_all_v1.sql');
 *----------------------------------------------------------------------
 */
class DbManage {
    var $db; // 数据库连接
    var $database; // 所用数据库
    var $sqldir; // 数据库备份文件夹
    // 换行符
    private $ds = "n";
    // 存储SQL的变量
    public $sqlContent = "";
    // 每条sql语句的结尾符
    public $sqlEnd = ";";

    /**
     * 初始化
     *
     * @param string $host
     * @param string $username
     * @param string $password
     * @param string $database
     * @param string $charset
     */
    function __construct($host = 'localhost', $username = 'root', $password = '', $database = 'test', $charset = 'utf8') {
        $this->host = $host;
        $this->username = $username;
        $this->password = $password;
        $this->database = $database;
        $this->charset = $charset;
        set_time_limit(0);//无时间限制
@ob_end_flush();
        // 连接数据库
        $this->db = @mysql_connect ( $this->host, $this->username, $this->password ) or die( '

Mysql Connect Error : '.mysql_error().'

');
        // 选择使用哪个数据库
        mysql_select_db ( $this->database, $this->db ) or die('

Mysql Connect Error:'.mysql_error().'

');
        // 数据库编码方式
        mysql_query ( 'SET NAMES ' . $this->charset, $this->db );

    }

    /*
     * 新增查询数据库表
     */
    function getTables() {
        $res = mysql_query ( "SHOW TABLES" );
        $tables = array ();
        while ( $row = mysql_fetch_array ( $res ) ) {
            $tables [] = $row [0];
        }
        return $tables;
    }

    /*
     *
     * ------------------------------------------数据库备份start----------------------------------------------------------
     */

    /**
     * 数据库备份
     * 参数:备份哪个表(可选),备份目录(可选,默认为backup),分卷大小(可选,默认2000,即2M)
     *
     * @param $string $dir
     * @param int $size
     * @param $string $tablename
     */
    function backup($tablename = '', $dir, $size) {
        $dir = $dir ? $dir : './backup/';
        // 创建目录
        if (! is_dir ( $dir )) {
            mkdir ( $dir, 0777, true ) or die ( '创建文件夹失败' );
        }
        $size = $size ? $size : 2048;
        $sql = '';
        // 只备份某个表
        if (! empty ( $tablename )) {
            if(@mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$tablename."'")) == 1) {
             } else {
                $this->_showMsg('表-' . $tablename .'-不存在,请检查!',true);
                die();
            }
            $this->_showMsg('正在备份表 ' . $tablename.'');
            // 插入dump信息
            $sql = $this->_retrieve ();
            // 插入表结构信息
            $sql .= $this->_insert_table_structure ( $tablename );
            // 插入数据
            $data = mysql_query ( "select * from " . $tablename );
            // 文件名前面部分
            $filename = date ( 'YmdHis' ) . "_" . $tablename;
            // 字段数量
            $num_fields = mysql_num_fields ( $data );
            // 第几分卷
            $p = 1;
            // 循环每条记录
            while ( $record = mysql_fetch_array ( $data ) ) {
                // 单条记录
                $sql .= $this->_insert_record ( $tablename, $num_fields, $record );
                // 如果大于分卷大小,则写入文件
                if (strlen ( $sql ) >= $size * 1024) {
                    $file = $filename . "_v" . $p . ".sql";
                    if ($this->_write_file ( $sql, $file, $dir )) {
                        $this->_showMsg("表-" . $tablename . "-卷-" . $p . "-数据备份完成,备份文件 [ " .$dir . $file ." ]");
                    } else {
                        $this->_showMsg("备份表 -" . $tablename . "- 失败",true);
                        return false;
                    }
                    // 下一个分卷
                    $p ++;
                    // 重置$sql变量为空,重新计算该变量大小
                    $sql = "";
                }
            }
            // 及时清除数据
            unset($data,$record);
            // sql大小不够分卷大小
            if ($sql != "") {
                $filename .= "_v" . $p . ".sql";
                if ($this->_write_file ( $sql, $filename, $dir )) {
                    $this->_showMsg( "表-" . $tablename . "-卷-" . $p . "-数据备份完成,备份文件 [ " .$dir . $filename ." ]");
                } else {
                    $this->_showMsg("备份卷-" . $p . "-失败
");
                    return false;
                }
            }
            $this->_showMsg("恭喜您! 备份成功");
        } else {
            $this->_showMsg('正在备份');
            // 备份全部表
            if ($tables = mysql_query ( "show table status from " . $this->database )) {
                $this->_showMsg("读取数据库结构成功!");
            } else {
                $this->_showMsg("读取数据库结构失败!");
                exit ( 0 );
            }
            // 插入dump信息
            $sql .= $this->_retrieve ();
            // 文件名前面部分
            $filename = date ( 'YmdHis' ) . "_all";
            // 查出所有表
            $tables = mysql_query ( 'SHOW TABLES' );
            // 第几分卷
            $p = 1;
            // 循环所有表
            while ( $table = mysql_fetch_array ( $tables ) ) {
                // 获取表名
                $tablename = $table [0];
                // 获取表结构
                $sql .= $this->_insert_table_structure ( $tablename );
                $data = mysql_query ( "select * from " . $tablename );
                $num_fields = mysql_num_fields ( $data );

                // 循环每条记录
                while ( $record = mysql_fetch_array ( $data ) ) {
                    // 单条记录
                    $sql .= $this->_insert_record ( $tablename, $num_fields, $record );
                    // 如果大于分卷大小,则写入文件
                    if (strlen ( $sql ) >= $size * 1000) {

                        $file = $filename . "_v" . $p . ".sql";
                        // 写入文件
                        if ($this->_write_file ( $sql, $file, $dir )) {
                            $this->_showMsg("-卷-" . $p . "-数据备份完成,备份文件 [ ".$dir.$file." ]");
                        } else {
                            $this->_showMsg("卷-" . $p . "-备份失败!",true);
                            return false;
                        }
                        // 下一个分卷
                        $p ++;
                        // 重置$sql变量为空,重新计算该变量大小
                        $sql = "";
                    }
                }
            }
            // sql大小不够分卷大小
            if ($sql != "") {
                $filename .= "_v" . $p . ".sql";
                if ($this->_write_file ( $sql, $filename, $dir )) {
                    $this->_showMsg("-卷-" . $p . "-数据备份完成,备份文件 [ ".$dir.$filename." ]");
                } else {
                    $this->_showMsg("卷-" . $p . "-备份失败",true);
                    return false;
                }
            }
            $this->_showMsg("恭喜您! 备份成功");
        }
    }

    //  及时输出信息
    private function _showMsg($msg,$err=false){
        $err = $err ? "ERROR:" : '' ;
        echo "

".$err . $msg."

";
        flush();

    }

    /**
     * 插入数据库备份基础信息
     *
     * @return string
     */
    private function _retrieve() {
        $value = '';
        $value .= '--' . $this->ds;
        $value .= '-- MySQL database dump' . $this->ds;
        $value .= '-- Created by DbManage class, Power By yanue. ' . $this->ds;
        $value .= '-- http://yanue.net ' . $this->ds;
        $value .= '--' . $this->ds;
        $value .= '-- 主机: ' . $this->host . $this->ds;
        $value .= '-- 生成日期: ' . date ( 'Y' ) . ' 年  ' . date ( 'm' ) . ' 月 ' . date ( 'd' ) . ' 日 ' . date ( 'H:i' ) . $this->ds;
        $value .= '-- MySQL版本: ' . mysql_get_server_info () . $this->ds;
        $value .= '-- PHP 版本: ' . phpversion () . $this->ds;
        $value .= $this->ds;
        $value .= '--' . $this->ds;
        $value .= '-- 数据库: `' . $this->database . '`' . $this->ds;
        $value .= '--' . $this->ds . $this->ds;
        $value .= '-- -------------------------------------------------------';
        $value .= $this->ds . $this->ds;
        return $value;
    }

    /**
     * 插入表结构
     *
     * @param unknown_type $table
     * @return string
     */
    private function _insert_table_structure($table) {
        $sql = '';
        $sql .= "--" . $this->ds;
        $sql .= "-- 表的结构" . $table . $this->ds;
        $sql .= "--" . $this->ds . $this->ds;

        // 如果存在则删除表
        $sql .= "DROP TABLE IF EXISTS `" . $table . '`' . $this->sqlEnd . $this->ds;
        // 获取详细表信息
        $res = mysql_query ( 'SHOW CREATE TABLE `' . $table . '`' );
        $row = mysql_fetch_array ( $res );
        $sql .= $row [1];
        $sql .= $this->sqlEnd . $this->ds;
        // 加上
        $sql .= $this->ds;
        $sql .= "--" . $this->ds;
        $sql .= "-- 转存表中的数据 " . $table . $this->ds;
        $sql .= "--" . $this->ds;
        $sql .= $this->ds;
        return $sql;
    }

    /**
     * 插入单条记录
     *
     * @param string $table
     * @param int $num_fields
     * @param array $record
     * @return string
     */
    private function _insert_record($table, $num_fields, $record) {
        // sql字段逗号分割
        $insert = '';
        $comma = "";
        $insert .= "INSERT INTO `" . $table . "` VALUES(";
        // 循环每个子段下面的内容
        for($i = 0; $i             $insert .= ($comma . "'" . mysql_escape_string ( $record [$i] ) . "'");
            $comma = ",";
        }
        $insert .= ");" . $this->ds;
        return $insert;
    }

    /**
     * 写入文件
     *
     * @param string $sql
     * @param string $filename
     * @param string $dir
     * @return boolean
     */
    private function _write_file($sql, $filename, $dir) {
        $dir = $dir ? $dir : './backup/';
        // 创建目录
        if (! is_dir ( $dir )) {
            mkdir ( $dir, 0777, true );
        }
        $re = true;
        if (! @$fp = fopen ( $dir . $filename, "w+" )) {
            $re = false;
            $this->_showMsg("打开sql文件失败!",true);
        }
        if (! @fwrite ( $fp, $sql )) {
            $re = false;
            $this->_showMsg("写入sql文件失败,请文件是否可写",true);
        }
        if (! @fclose ( $fp )) {
            $re = false;
            $this->_showMsg("关闭sql文件失败!",true);
        }
        return $re;
    }

    /*
     *
     * -------------------------------上:数据库导出-----------分割线----------下:数据库导入--------------------------------
     */

    /**
     * 导入备份数据
     * 说明:分卷文件格式20120516211738_all_v1.sql
     * 参数:文件路径(必填)
     *
     * @param string $sqlfile
     */
    function restore($sqlfile) {
        // 检测文件是否存在
        if (! file_exists ( $sqlfile )) {
            $this->_showMsg("sql文件不存在!请检查",true);
            exit ();
        }
        $this->lock ( $this->database );
        // 获取数据库存储位置
        $sqlpath = pathinfo ( $sqlfile );
        $this->sqldir = $sqlpath ['dirname'];
        // 检测是否包含分卷,将类似20120516211738_all_v1.sql从_v分开,有则说明有分卷
        $volume = explode ( "_v", $sqlfile );
        $volume_path = $volume [0];
        $this->_showMsg("请勿刷新及关闭浏览器以防止程序被中止,如有不慎!将导致数据库结构受损");
        $this->_showMsg("正在导入备份数据,请稍等!");
        if (empty ( $volume [1] )) {
            $this->_showMsg ( "正在导入sql:" . $sqlfile . '');
            // 没有分卷
            if ($this->_import ( $sqlfile )) {
                $this->_showMsg( "数据库导入成功!");
            } else {
                 $this->_showMsg('数据库导入失败!',true);
                exit ();
            }
        } else {
            // 存在分卷,则获取当前是第几分卷,循环执行余下分卷
            $volume_id = explode ( ".sq", $volume [1] );
            // 当前分卷为$volume_id
            $volume_id = intval ( $volume_id [0] );
            while ( $volume_id ) {
                $tmpfile = $volume_path . "_v" . $volume_id . ".sql";
                // 存在其他分卷,继续执行
                if (file_exists ( $tmpfile )) {
                    // 执行导入方法
                    $this->msg .= "正在导入分卷 $volume_id :" . $tmpfile . '
';
                    if ($this->_import ( $tmpfile )) {

                    } else {
                        $volume_id = $volume_id ? $volume_id :1;
                        exit ( "导入分卷:" . $tmpfile . '失败!可能是数据库结构已损坏!请尝试从分卷1开始导入' );
                    }
                } else {
                    $this->msg .= "此分卷备份全部导入成功!
";
                    return;
                }
                $volume_id ++;
            }
        }if (empty ( $volume [1] )) {
            $this->_showMsg ( "正在导入sql:" . $sqlfile . '');
            // 没有分卷
            if ($this->_import ( $sqlfile )) {
                $this->_showMsg( "数据库导入成功!");
            } else {
                 $this->_showMsg('数据库导入失败!',true);
                exit ();
            }
        } else {
            // 存在分卷,则获取当前是第几分卷,循环执行余下分卷
            $volume_id = explode ( ".sq", $volume [1] );
            // 当前分卷为$volume_id
            $volume_id = intval ( $volume_id [0] );
            while ( $volume_id ) {
                $tmpfile = $volume_path . "_v" . $volume_id . ".sql";
                // 存在其他分卷,继续执行
                if (file_exists ( $tmpfile )) {
                    // 执行导入方法
                    $this->msg .= "正在导入分卷 $volume_id :" . $tmpfile . '
';
                    if ($this->_import ( $tmpfile )) {

                    } else {
                        $volume_id = $volume_id ? $volume_id :1;
                        exit ( "导入分卷:" . $tmpfile . '失败!可能是数据库结构已损坏!请尝试从分卷1开始导入' );
                    }
                } else {
                    $this->msg .= "此分卷备份全部导入成功!
";
                    return;
                }
                $volume_id ++;
            }
        }
    }

    /**
     * 将sql导入到数据库(普通导入)
     *
     * @param string $sqlfile
     * @return boolean
     */
    private function _import($sqlfile) {
        // sql文件包含的sql语句数组
        $sqls = array ();
        $f = fopen ( $sqlfile, "rb" );
        // 创建表缓冲变量
        $create_table = '';
        while ( ! feof ( $f ) ) {
            // 读取每一行sql
            $line = fgets ( $f );
            // 这一步为了将创建表合成完整的sql语句
            // 如果结尾没有包含';'(即为一个完整的sql语句,这里是插入语句),并且不包含'ENGINE='(即创建表的最后一句)
            if (! preg_match ( '/;/', $line ) || preg_match ( '/ENGINE=/', $line )) {
                // 将本次sql语句与创建表sql连接存起来
                $create_table .= $line;
                // 如果包含了创建表的最后一句
                if (preg_match ( '/ENGINE=/', $create_table)) {
                    //执行sql语句创建表
                    $this->_insert_into($create_table);
                    // 清空当前,准备下一个表的创建
                    $create_table = '';
                }
                // 跳过本次
                continue;
            }
            //执行sql语句
            $this->_insert_into($line);
        }
        fclose ( $f );
        return true;
    }

    //插入单条sql语句
    private function _insert_into($sql){
        if (! mysql_query ( trim ( $sql ) )) {
            $this->msg .= mysql_error ();
            return false;
        }
    }

    /*
     * -------------------------------数据库导入end---------------------------------
     */

    // 关闭数据库连接
    private function close() {
        mysql_close ( $this->db );
    }

    // 锁定数据库,以免备份或导入时出错
    private function lock($tablename, $op = "WRITE") {
        if (mysql_query ( "lock tables " . $tablename . " " . $op ))
            return true;
        else
            return false;
    }

    // 解锁
    private function unlock() {
        if (mysql_query ( "unlock tables" ))
            return true;
        else
            return false;
    }

    // 析构
    function __destruct() {
        if($this->db){
            mysql_query ( "unlock tables", $this->db );
            mysql_close ( $this->db );
        }
    }

}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/630687.htmlTechArticle分卷处理就是把握们要处理的数据分成一个个小文件进行处理了,下面我来给大家介绍一个php mysql备份恢复分卷处理类,实现mysql数据库分卷...
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
PHP和Python:解释了不同的范例PHP和Python:解释了不同的范例Apr 18, 2025 am 12:26 AM

PHP主要是过程式编程,但也支持面向对象编程(OOP);Python支持多种范式,包括OOP、函数式和过程式编程。PHP适合web开发,Python适用于多种应用,如数据分析和机器学习。

PHP和Python:深入了解他们的历史PHP和Python:深入了解他们的历史Apr 18, 2025 am 12:25 AM

PHP起源于1994年,由RasmusLerdorf开发,最初用于跟踪网站访问者,逐渐演变为服务器端脚本语言,广泛应用于网页开发。Python由GuidovanRossum于1980年代末开发,1991年首次发布,强调代码可读性和简洁性,适用于科学计算、数据分析等领域。

在PHP和Python之间进行选择:指南在PHP和Python之间进行选择:指南Apr 18, 2025 am 12:24 AM

PHP适合网页开发和快速原型开发,Python适用于数据科学和机器学习。1.PHP用于动态网页开发,语法简单,适合快速开发。2.Python语法简洁,适用于多领域,库生态系统强大。

PHP和框架:现代化语言PHP和框架:现代化语言Apr 18, 2025 am 12:14 AM

PHP在现代化进程中仍然重要,因为它支持大量网站和应用,并通过框架适应开发需求。1.PHP7提升了性能并引入了新功能。2.现代框架如Laravel、Symfony和CodeIgniter简化开发,提高代码质量。3.性能优化和最佳实践进一步提升应用效率。

PHP的影响:网络开发及以后PHP的影响:网络开发及以后Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP类型提示如何起作用,包括标量类型,返回类型,联合类型和无效类型?PHP类型提示如何起作用,包括标量类型,返回类型,联合类型和无效类型?Apr 17, 2025 am 12:25 AM

PHP类型提示提升代码质量和可读性。1)标量类型提示:自PHP7.0起,允许在函数参数中指定基本数据类型,如int、float等。2)返回类型提示:确保函数返回值类型的一致性。3)联合类型提示:自PHP8.0起,允许在函数参数或返回值中指定多个类型。4)可空类型提示:允许包含null值,处理可能返回空值的函数。

PHP如何处理对象克隆(克隆关键字)和__clone魔法方法?PHP如何处理对象克隆(克隆关键字)和__clone魔法方法?Apr 17, 2025 am 12:24 AM

PHP中使用clone关键字创建对象副本,并通过\_\_clone魔法方法定制克隆行为。1.使用clone关键字进行浅拷贝,克隆对象的属性但不克隆对象属性内的对象。2.通过\_\_clone方法可以深拷贝嵌套对象,避免浅拷贝问题。3.注意避免克隆中的循环引用和性能问题,优化克隆操作以提高效率。

PHP与Python:用例和应用程序PHP与Python:用例和应用程序Apr 17, 2025 am 12:23 AM

PHP适用于Web开发和内容管理系统,Python适合数据科学、机器学习和自动化脚本。1.PHP在构建快速、可扩展的网站和应用程序方面表现出色,常用于WordPress等CMS。2.Python在数据科学和机器学习领域表现卓越,拥有丰富的库如NumPy和TensorFlow。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 个月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
1 个月前By尊渡假赌尊渡假赌尊渡假赌
威尔R.E.P.O.有交叉游戏吗?
1 个月前By尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

SecLists

SecLists

SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境