MySQL_Connector_Arduino icon indicating copy to clipboard operation
MySQL_Connector_Arduino copied to clipboard

get_rows_affected() always returns a -1?

Open taper42 opened this issue 8 months ago • 1 comments

Hello!

I have been using your connector for some time already - thank you for this marvelous connector!

I wanted these days to see how many rows my query returns and found get_rows_affected() in the src, but absolutely no mention of it on the web tho :) so I tried it and gets me a -1 every time.

Everything else works perfectly, using the "query_results" example, it is fetching all the columns names and values, but the affected rows is -1.

The query is: char query[] = "SELECT * FROM cam.t WHERE DATE (date_opening) = CURDATE() ORDER BY date_opening DESC LIMIT 0 , 100";

and I expect a result of no more than 15 rows on any given day, but there are some 20k records in this table. Today's result is 1 for the first part, now is 2, if that matters.

The query also works perfectly in phpmyadmin. Mysql log shows no error for this query

this is what I added to the example (towards the end of the loop():

  } while (row != NULL);
  
  // my try for get_rows_affected()
  int nr = cur_mem->get_rows_affected();
  Serial.print("\n\r #: ");
  Serial.print(nr);
  
  // Deleting the cursor also frees up memory used
  delete cur_mem;
  delay(180000); (any less will trigger the MySQL server  for a day run:)

(and there is the WiFi initialization too, which is standard).

thank you and best regards

taper42 avatar Jun 11 '24 08:06 taper42