代码拉取完成,页面将自动刷新
#include "db_installed_imformation.h"
Installed_imformation::Installed_imformation()
{
QString db_path = "/usr/share/kylin-update-manager/original/kylin-update-manager_1.db";
QFile file;
if(file.exists(db_path))
{
//设置数据库驱动名称
this->database=QSqlDatabase::addDatabase("QSQLITE");
//设置数据库名
this->database.setDatabaseName(db_path);
//看是否能正确打开
if(!this->database.open())
{
// qDebug()<<database.lastError().text();
qDebug()<<"打开失败";
}
else
{
qDebug()<<"数据库打开成功!";
}
}
}
void Installed_imformation::select()
{
QSqlQuery sql_select;
QString select_sql = "select * from installed order by time desc";
sql_select.prepare(select_sql);
if(!sql_select.exec())
{
qDebug()<<"select error";
}
else
{
while(sql_select.next())
{
appname = sql_select.value(0).toString();
version = sql_select.value(1).toString();
now_time = sql_select.value(2).toString();
description = sql_select.value(3).toString();
icon = sql_select.value(4).toString();
statue = sql_select.value(5).toString();
}
}
}
bool Installed_imformation::insert(QString appname, QString version,QString description, QString icon,QString statue)
{
QSqlQuery sql_insert;
time_t time1 = time(NULL);
tm *time2;
time2 = localtime(&time1);
time2->tm_year = time2->tm_year;
char tmp[512] = {};
strftime(tmp,sizeof(tmp),"%Y-%m-%d %H:%M:%S",time2);
QString time3 = tmp;
qDebug()<<appname<<version<<description<<icon<<statue;
QString insert_msg = "insert into installed values(?,?,?,?,?,?)";
sql_insert.prepare(insert_msg);
sql_insert.addBindValue(appname);
sql_insert.addBindValue(version);
sql_insert.addBindValue(tmp);
sql_insert.addBindValue(description);
sql_insert.addBindValue(icon);
sql_insert.addBindValue(statue);
//bool re = sql_insert.exec(insert_msg)
if(!sql_insert.exec())
{
qDebug() << "insert error";
}
else
{
qDebug() << "inserted seccuss!";
}
sql_insert.finish();
database.close();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。