1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
conn = mysql_init(NULL);
mysql_real_connect(conn,"","root","root","trafficdetails",0,NULL,0);
std::cout << "Total: " << totalcount << " vehicles" << std::endl;
////std::cout << totalcount/14 << std::endl;
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
char buffer1 [80];
char buffer2 [80];
time (&rawtime);
timeinfo = localtime (&rawtime);
////strftime (buffer,80,"%c:%A",timeinfo);
strftime (buffer,80,"%T",timeinfo);
strftime (buffer1,80,"%A",timeinfo);
////strftime (buffer2,80,"%R",timeinfo);
////puts (buffer);
////printf(buffer);
std::ostringstream query,query1,query2,query3,query4,query5,query6;
////query0 << "Insert into details values ( NOW(),'" << buffer << "' ,'" << totalcount << "','" << buffer1 << "' )";
query << "Insert into monday values ('" << buffer << "','" << totalcount << "')";
query1 << "Insert into tuesday values ('" << buffer << "','" << totalcount << "')";
query2 << "Insert into wednesday values('" << buffer << "','" << totalcount << "')";
query3 << "Insert into thursday values ('" << buffer << "','" << totalcount << "')";
query4 << "Insert into friday values ('" << buffer << "','" << totalcount << "')";
query5 << "Insert into saturday values ('" << buffer << "','" << totalcount << "')";
query6 << "Insert into sunday values ('" << buffer << "','" << totalcount << "')";
/*mysql_query(conn, query1.str().c_str());
mysql_query(conn, query2.str().c_str());
mysql_query(conn, query3.str().c_str());
mysql_query(conn, query4.str().c_str());
mysql_query(conn, query5.str().c_str());
mysql_query(conn, query6.str().c_str());*/
//string compare
if(buffer1=="Monday")
{
mysql_query(conn, query.str().c_str());
}
else if(buffer1=="Tuesday")
{
mysql_query(conn, query1.str().c_str());
}
else if(buffer1=="Wednesday")
{
mysql_query(conn, query2.str().c_str());
}
else if(buffer1=="Thursday")
{
mysql_query(conn, query3.str().c_str());
}
else if(buffer1=="Friday")
{
mysql_query(conn, query4.str().c_str());
}
else if(buffer1=="Saturday")
{
mysql_query(conn, query5.str().c_str());
}
else
{
mysql_query(conn, query6.str().c_str());
}
|