如何使用php代码或codeigniter代码下载.sql文件!
How Can I download .sql file using php code or codeigniter code!
推荐答案$this->dbutil->backup()
允许您备份整个数据库或单个表.备份数据可以Zip或Gzip格式压缩.
Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format.
注意:此功能仅适用于MySQL数据库.注意:由于PHP的执行时间和内存有限,可能无法备份非常大的数据库.如果数据库很大,则可能需要通过命令行直接从SQL Server进行备份,或者,如果您没有root特权,请让服务器管理员为您进行备份.
Note: This features is only available for MySQL databases. Note: Due to the limited execution time and memory available to PHP, backing up very large databases may not be possible. If your database is very large you might need to backup directly from your SQL server via the command line, or have your server admin do it for you if you do not have root privileges.
用法示例
// Load the DB utility class $this->load->dbutil(); // Backup your entire database and assign it to a variable $backup =& $this->dbutil->backup(); // Load the file helper and write the file to your server $this->load->helper('file'); write_file('/path/to/mybackup.sql', $backup); // Load the download helper and send the file to your desktop $this->load->helper('download'); force_download('mybackup.sql', $backup);跟踪链接
更多推荐
如何使用PHP代码或Codeigniter以.sql扩展名导出mysql数据库
发布评论