速度能有几十倍的提升
示例:
bool TelephoneDb::InsertAllAddress(std::map<QString, TelephoneAddress> & addresses)
{
db_.transaction();//事务
QString sql;
for(std::map<QString,TelephoneAddress>::iterator it = addresses.begin();it != addresses.end();++it){
sql = "insert into address values ('" + it->second.id + "','" + it->second.number + "','" + it->second.name + "')";
if(!query_.exec(sql)){
SqlError();
}
}
db_.commit();
return true;
}