php生成sqlite db3文件遇到的问题
时间:2013-05-24
来源:互联网
$db = new SQLite3('test.db3');
$db->exec("CREATE TABLE table_1 (
id int(11) NOT NULL ,
lessons_id int(11) NOT NULL,
name varchar(100) NOT NULL,
url varchar(200) NOT NULL,
time int(11) NOT NULL ,
PRIMARY KEY (id)
) ;
INSERT INTO table_1 VALUES ('161', '3583', '背影', 'http://www.test.com/upload/table_1/1369122019-1720.png', '1362988823');INSERT INTO table_1 VALUES ('162', '3583', '从百草园到三味书屋', 'http://www.test.com/upload/table_1/1369122067-9894.png', '1363939234');
INSERT INTO table_1 VALUES ('163', '3583', '繁星', 'http://www.test.com/upload/table_1/1369122095-8678.png', '1364457656');
INSERT INTO table_1 VALUES ('164', '3583', '沁园春', 'http://www.test.com/upload/table_1/1369122117-4050.png', '1365753667');
INSERT INTO table_1 VALUES ('165', '3583', '桃花园记', 'http://www.test.com/upload/table_1/1369122178-5256.png', '1366963200');
INSERT INTO table_1 VALUES ('166', '3583', '晏子使楚', 'http://www.test.com/upload/table_1/1369122201-5046.png', '1368604800');
INSERT INTO table_1 VALUES ('167', '3583', '卜算子咏梅', 'http://www.test.com/upload/table_1/1369122242-8847.png', '1369123200');INSERT INTO table_1 VALUES ('176', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522143123rop.png', '1369204283');
INSERT INTO table_1 VALUES ('175', '3583', '1-3583', 'http://www.test.com/upload/table_1/201305221431188h6.png', '1369204278');
INSERT INTO table_1 VALUES ('174', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522142126dkj.png', '1369203686');
INSERT INTO table_1 VALUES ('177', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522143552zuy.png', '1369204552');
INSERT INTO table_1 VALUES ('178', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522143555ln8.png', '1369204555');
INSERT INTO table_1 VALUES ('179', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522152943st3.png', '1369207783');");
功能可以实现,但是效率太慢,平均每10条数据一秒,如果上万条数据,非常慢,求解!
$db->exec("CREATE TABLE table_1 (
id int(11) NOT NULL ,
lessons_id int(11) NOT NULL,
name varchar(100) NOT NULL,
url varchar(200) NOT NULL,
time int(11) NOT NULL ,
PRIMARY KEY (id)
) ;
INSERT INTO table_1 VALUES ('161', '3583', '背影', 'http://www.test.com/upload/table_1/1369122019-1720.png', '1362988823');INSERT INTO table_1 VALUES ('162', '3583', '从百草园到三味书屋', 'http://www.test.com/upload/table_1/1369122067-9894.png', '1363939234');
INSERT INTO table_1 VALUES ('163', '3583', '繁星', 'http://www.test.com/upload/table_1/1369122095-8678.png', '1364457656');
INSERT INTO table_1 VALUES ('164', '3583', '沁园春', 'http://www.test.com/upload/table_1/1369122117-4050.png', '1365753667');
INSERT INTO table_1 VALUES ('165', '3583', '桃花园记', 'http://www.test.com/upload/table_1/1369122178-5256.png', '1366963200');
INSERT INTO table_1 VALUES ('166', '3583', '晏子使楚', 'http://www.test.com/upload/table_1/1369122201-5046.png', '1368604800');
INSERT INTO table_1 VALUES ('167', '3583', '卜算子咏梅', 'http://www.test.com/upload/table_1/1369122242-8847.png', '1369123200');INSERT INTO table_1 VALUES ('176', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522143123rop.png', '1369204283');
INSERT INTO table_1 VALUES ('175', '3583', '1-3583', 'http://www.test.com/upload/table_1/201305221431188h6.png', '1369204278');
INSERT INTO table_1 VALUES ('174', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522142126dkj.png', '1369203686');
INSERT INTO table_1 VALUES ('177', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522143552zuy.png', '1369204552');
INSERT INTO table_1 VALUES ('178', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522143555ln8.png', '1369204555');
INSERT INTO table_1 VALUES ('179', '3583', '1-3583', 'http://www.test.com/upload/table_1/20130522152943st3.png', '1369207783');");
功能可以实现,但是效率太慢,平均每10条数据一秒,如果上万条数据,非常慢,求解!
作者: vinson_han 发布时间: 2013-05-24
使用事务啊。如果在没有使用事务的情况下每次执行都会自动代表一次事务进行数据库读写,而不是在内存中操作,效率自然很低。
作者: iminto 发布时间: 2013-05-24
事务不仅仅是可以保证数据一致性,还能提高数据插入效率,达到批量插入的效果
作者: iminto 发布时间: 2013-05-24
相关阅读 更多
热门阅读
- office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
- 如何安装mysql8.0
阅读:31
- Word快速设置标题样式步骤详解
阅读:28
- 20+道必知必会的Vue面试题(附答案解析)
阅读:37
- HTML如何制作表单
阅读:22
- 百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
- ET文件格式和XLS格式文件之间如何转化?
阅读:24
- react和vue的区别及优缺点是什么
阅读:121
- 支付宝人脸识别如何关闭?
阅读:21
- 腾讯微云怎么修改照片或视频备份路径?
阅读:28