int ypalilos::db_add() {/*Vriskei neo ID kai kataxorei to record stin vasi */ Database mydb; char* myStatement; char* server = "localhost"; //I diefthinsi tou server, ta vazoume fixed gia efkolia char* datb = "texnologia"; //I database pou xrisimopoioume, fixed gia efkolia char* usr = "root"; //username, root, fixed gia efkolia (me null pw) char* pwd = ""; //null pw Result rs; //apotelesmata tou select Row rw; //se grammes Result::iterator itr; //counter int id; bool tflag; myStatement= "select * from problems"; //Diavazoume oles tis egrafes rs = mydb.executeSQL(server, datb, usr, pwd,myStatement); //Dinoume to query for ( itr = rs.begin(); itr != rs.end();) { rw = *itr; if (id==atoi(rw["id"].c_str())){itr = rs.begin(); id++;} else itr++; } data.id = id; //Edidi exoume strings kai char* to grapsimo ginete ligo periploko.. sprintf(myStatement,"insert into problems values('%d', '%s','%u','%d','%d')",data.id,data.onoma.c_str(), data.tel, data.category, data.condition); mydb.executeSQL(server, datb, usr, pwd,myStatement); cout << "Operation done\n"; return id; }