尽管在session还有很多问题,最近还是做了一个小实验。现在,数据库里的内容比较少,看看CI的数据库备份资料的代码。
在所谓的菜单小实验中,有一项指向了start控制器中的another_function方法(函数),就拿它做实验啦!
其代码为:
function another_function()
{
$this->load->dbutil();
$prefs = array(
'format' => 'txt', // gzip, zip, txt
'newline' => "\r\n" // Newline character used in backup file
);
$backup =& $this->dbutil->backup($prefs);
$this->load->helper('file');
write_file('f:/mybackup.txt', $backup);
$this->load->helper('download');
$data1 = file_get_contents("f:/mybackup.txt");
$name = 'backup.txt';
force_download($name, $data1);
}
其结果呢,在XP的桌面上出现了备份文本文件,backup.txt内容如下:
#
# TABLE STRUCTURE FOR: ci_sessions
#
DROP TABLE IF EXISTS ci_sessions;
CREATE TABLE `ci_sessions` (
`session_id` varchar(40) CHARACTER SET utf8 NOT NULL DEFAULT '0',
`ip_address` varchar(16) NOT NULL DEFAULT '0',
`user_agent` varchar(50) NOT NULL,
`last_activity` int(10) unsigned NOT NULL DEFAULT '0',
`STATUS` varchar(5) DEFAULT 'no',
PRIMARY KEY (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('2f6f9921472037fb75d9d2c8e544518b', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328149962, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('533840c838e739b1cfc9b4e1daf29454', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 0, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('5ef9740a95d09add115e329a8dfafb3b', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328665322, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('6e4a21e467b2153a3c15b70cd9cbcdd0', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 0, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('75c6455b39e40099fbc7277c7f1ef283', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328200524, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('a055a8b61432948e7e1d1d3094c10186', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328151001, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('b73ab2ff716b2a380f1ef8b0eb430d97', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328723770, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('bd6aadbd29b10573d8562b28d744855d', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328150494, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('c0445c36819cafb1b63ca34d8291d834', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328461503, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('c784f2416a5cec45432feb762e1fe0f1', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328201262, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('d3d97ea3febeae2ec65536de1c95a08c', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328634126, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('e4435247a07402aeff042d1a3078fdab', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328663667, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('f55190615d2c9a8eb261b94dda5c4032', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328806203, 'OK');
INSERT INTO ci_sessions (`session_id`, `ip_address`, `user_agent`, `last_activity`, `STATUS`) VALUES ('f73d97d3a70eaf48a0041ca48dd0b1db', '127.0.0.1', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;', 1328723874, 'OK');
#
# TABLE STRUCTURE FOR: domains
#
DROP TABLE IF EXISTS domains;
CREATE TABLE `domains` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`url` varchar(100) NOT NULL,
`name` varchar(100) NOT NULL,
`registrar` varchar(100) NOT NULL,
`dateregd` int(11) NOT NULL DEFAULT '0',
`cost` float NOT NULL DEFAULT '0',
`regdfor` int(11) NOT NULL DEFAULT '0',
`notes` blob NOT NULL,
`pw` varchar(25) NOT NULL,
`un` varchar(25) NOT NULL,
`lastupdate` int(11) NOT NULL DEFAULT '0',
`submit` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
#
# TABLE STRUCTURE FOR: events
#
DROP TABLE IF EXISTS events;
CREATE TABLE `events` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT 'not set',
`type` enum('test','alert','report') NOT NULL,
`testid` int(10) NOT NULL,
`siteid` int(10) NOT NULL,
`userid` int(10) NOT NULL,
`reported` int(11) NOT NULL,
`result` blob NOT NULL,
`TIME` int(11) NOT NULL,
`timetaken` float NOT NULL,
`isalert` varchar(2) NOT NULL,
`emailid` int(11) NOT NULL,
`submit` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=69 DEFAULT CHARSET=utf8;
#
# TABLE STRUCTURE FOR: frequencies
#
DROP TABLE IF EXISTS frequencies;
CREATE TABLE `frequencies` (
`id` int(10) NOT NULL,
`name` varchar(16) NOT NULL,
`submit` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
#
# TABLE STRUCTURE FOR: hosts
#
DROP TABLE IF EXISTS hosts;
CREATE TABLE `hosts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cost` float NOT NULL,
`name` varchar(100) NOT NULL,
`hosturl` varchar(100) NOT NULL,
`un` varchar(50) NOT NULL,
`pw` varchar(50) NOT NULL,
`ns1url` varchar(36) NOT NULL,
`ns1ip` varchar(36) NOT NULL,
`ns2url` varchar(36) NOT NULL,
`ns2ip` varchar(36) NOT NULL,
`ftpurl` varchar(100) NOT NULL,
`ftpserverip` varchar(36) NOT NULL,
`ftpun` varchar(50) NOT NULL,
`ftppw` varchar(50) NOT NULL,
`cpurl` varchar(36) NOT NULL,
`cpun` varchar(36) NOT NULL,
`cppw` varchar(36) NOT NULL,
`pop3server` varchar(36) NOT NULL,
`servicetel` varchar(50) NOT NULL,
`servicetel2` varchar(50) NOT NULL,
`serviceemail` varchar(100) NOT NULL,
`webroot` varchar(48) NOT NULL,
`absoluteroot` varchar(48) NOT NULL,
`cgiroot` varchar(48) NOT NULL,
`booked` int(11) NOT NULL,
`duration` int(11) NOT NULL,
`lastupdate` int(11) NOT NULL DEFAULT '0',
`submit` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
#
# TABLE STRUCTURE FOR: people
#
DROP TABLE IF EXISTS people;
CREATE TABLE `people` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uname` varchar(25) NOT NULL,
`pw` varchar(25) NOT NULL,
`status` smallint(3) NOT NULL DEFAULT '1',
`name` varchar(50) NOT NULL,
`firstname` varchar(50) NOT NULL,
`surname` varchar(50) NOT NULL,
`email` varchar(120) NOT NULL,
`lastupdate` int(11) NOT NULL DEFAULT '0',
`submit` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
#
# TABLE STRUCTURE FOR: sites
#
DROP TABLE IF EXISTS sites;
CREATE TABLE `sites` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`url` varchar(100) NOT NULL,
`un` varchar(50) NOT NULL,
`pw` varchar(50) NOT NULL,
`client1` int(10) NOT NULL DEFAULT '0',
`client2` int(10) NOT NULL DEFAULT '0',
`admin1` int(10) NOT NULL DEFAULT '0',
`admin2` int(10) NOT NULL DEFAULT '0',
`domainid` int(10) NOT NULL DEFAULT '0',
`hostid` int(10) NOT NULL DEFAULT '0',
`webroot` varchar(50) NOT NULL,
`files` text NOT NULL,
`filesdate` int(11) NOT NULL DEFAULT '0',
`lastupdate` int(11) NOT NULL DEFAULT '0',
`submit` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
#
# TABLE STRUCTURE FOR: tests
#
DROP TABLE IF EXISTS tests;
CREATE TABLE `tests` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`siteid` int(11) NOT NULL DEFAULT '0',
`name` varchar(250) NOT NULL,
`type` varchar(25) NOT NULL,
`url` varchar(120) NOT NULL,
`regex` varchar(250) NOT NULL,
`p1` varchar(250) NOT NULL,
`p2` varchar(250) NOT NULL,
`p3` varchar(250) NOT NULL,
`p4` varchar(250) NOT NULL,
`p5` varchar(250) NOT NULL,
`p6` varchar(250) NOT NULL,
`frequency` int(10) NOT NULL DEFAULT '0',
`lastdone` int(10) NOT NULL DEFAULT '0',
`isalert` varchar(2) NOT NULL,
`setup` int(10) NOT NULL DEFAULT '0',
`lastupdate` int(10) NOT NULL DEFAULT '0',
`notes` varchar(250) NOT NULL,
`submit` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
#
# TABLE STRUCTURE FOR: types
#
DROP TABLE IF EXISTS types;
CREATE TABLE `types` (
`id` varchar(7) NOT NULL,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
原来备份的内容是这个样子,注意一点的是,在windows系统中的设置:
$prefs = array(
'format' => 'txt', // gzip, zip, txt
'newline' => "\r\n" // Newline character used in backup file
);
尤其是第二行!
问题依然很多。。。。。。。。。。。。