fixed memory leak in database, fixed wrong carid in races, some updates

This commit is contained in:
2014-09-13 16:14:24 +02:00
parent 990a6ad03d
commit b18e3f9943
12 changed files with 342 additions and 62 deletions

View File

@@ -13,10 +13,32 @@ DataBase::DataBase()
this->db->setDatabaseName("Renndatenbank.sqlite");
std::cout << "Konstruktor Database" << std::endl;
}
vector< vector<QString> > DataBase::getData2(std::string statement, int cols){
vector<QString> data;
vector< vector<QString> > lines;
bool ok = this->db->open();
QString qstr;
if(ok){
QSqlQuery query;
query.exec(QString::fromStdString(statement));
while(query.next()){
for(int i = 0; i < cols; i++){
qstr = query.value(i).toString();
data.push_back(qstr);
}
lines.push_back(data);
data.erase(data.begin(), data.begin()+cols);
}
}
this->db->close();
return lines;
}
vector< vector<QString> > DataBase::getData(std::string statement, int cols){
char * buffer = new char[statement.length()-1];
char * buffer = new char[statement.length()+1];
strcpy(buffer,statement.c_str());
vector<QString> data;
vector< vector<QString> > lines;
@@ -36,11 +58,12 @@ vector< vector<QString> > DataBase::getData(std::string statement, int cols){
}
}
this->db->close();
delete[] buffer;
return lines;
}
void DataBase::setData(std::string statement){
char * buffer = new char[statement.length()];
char * buffer = new char[statement.length()+1];
strcpy(buffer,statement.c_str());
bool ok = this->db->open();
if(ok){