+ "select value from %scnt order by timestamp desc limit 1;\n",
+ table);
+ if ((rc = mysql_query(&mysql, statement)))
+ g_warning("mysql \"%s\" error: %s\n",
+ statement, mysql_error(&mysql));
+ else if ((result = mysql_store_result(&mysql))){
+ MYSQL_ROW row = mysql_fetch_row(result);
+ if (row && *row) prev_val = atoi(*row);
+ mysql_free_result(result);
+ }
+ if (val <= prev_val) {
+ snprintf(statement, sizeof(statement),
+ "insert into %sadj values (\"%s\",%u);\n",
+ table, tstr, prev_val);
+ g_info("%s %u <= %u, %s", table, val, prev_val, statement);
+ if ((rc = mysql_query(&mysql, statement)))
+ g_warning("mysql \"%s\" error: %s\n",
+ statement, mysql_error(&mysql));
+ }
+ snprintf(statement, sizeof(statement),
+ "insert into %scnt values (\"%s\",%u);\n",