This article describes how thinkPHP uses pclzip to package and back up mysql databases. it analyzes thinkPHP's skills in using pclzip to compress files in the form of examples, for more information about how thinkPHP uses pclzip to package and back up mysql databases, see the following example. We will share this with you for your reference. The details are as follows:
PclZip introduces how to compress and decompress Zip files (WinZip and PKZIP) in the PclZip library and process such files, this includes generating compressed files, listing compressed files, and extracting files.
Database Backup is a very important thing. many backup methods also use vps for direct backup, and some use phpmyadmin for data backup. The small editor thinks this is troublesome and the backed up SQL file is too large to occupy a certain amount of space. Therefore, using pclzip to compress SQL files saves some space. Before Xiaobian has written database backup code here will not repeat, Pclzip official: http://www.phpconcept.net/pclzip/pclzip-downloads (the latest version of 2-8-2 ).
This site.
Find file_put_contents in the DatabaseAction. class. php file and add the following code below:
Import ("ORG. util. pclZip "); $ archive = new PclZip ('. /data /'. date ("y-m-d" ).'.zip '); $ v_list = $ archive-> create ($ dir); if (file_exists ($ dir) & $ v_list! = 0) {$ this-> success ("backup succeeded & compressed");} else {die ("Error :". $ archive-> errorInfo (true); $ this-> error ("backup failed ");}
And delete the original DatabaseAction. class. php if.