Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_rows_affected() always returns a -1? #231

Open
taper42 opened this issue Jun 11, 2024 · 1 comment
Open

get_rows_affected() always returns a -1? #231

taper42 opened this issue Jun 11, 2024 · 1 comment

Comments

@taper42
Copy link

taper42 commented Jun 11, 2024

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

@ChuckBell
Copy link
Owner

ChuckBell commented Jun 22, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants