Ad
Using Mysql C API For C++ Codes
I'm writing a c++ connector to a mysql datdabase and the only thing that I have is mysql.com references and everything here is for C and I wanted to see if it's ok to use this API for c++ codes or not? for example for the affected row we have
char *stmt = "UPDATE products SET cost=cost*1.25
WHERE group=10";
mysql_query(&mysql,stmt);
printf("%ld products updated",
(long) mysql_affected_rows(&mysql));
and is it same for cpp?
And I'm talking about this because we have somthing like this for c++ but not for C:
sql::ResultSet *res;
while(res->next()){
columnNames[i-1] = res->getString(i);
i++;
}
note that this just a part of a code
Ad
Answer
Yes, any C library can be used in C++ code. Just like Joachim Pileborg has mentioned in the comment.
this is just a code snippet from one of my project. I think you are looking for something like this.
MYSQL_ROW row;
while ((row = mysql_fetch_row(result)))
{
for(int i = 0; i < num_fields; i++)
{
// printf("%s \n", row[i] ? row[i] : "NULL");
char* new = malloc(100);
prtid[a]= new;
strcpy(prtid[a],row[i]);
}
a++;
}
Here is the link, If you want to study more
Ad
source: stackoverflow.com
Related Questions
- → Comparing two large files are taking over four hours
- → Setting JSON node name to variable value
- → Compiling GLUT using Emscripten
- → Evaluate check box from a scanned image in node.js
- → Find an easy web server framework for mobile game
- → my https C++ code doesn't work on some sites (binance)
- → Error while opening pivx wallet on ubuntu
- → Why sending a POST by AJAX is interpreted by the HTTP Server as OPTIONS and sending by CURL is effectively a PUT?
- → Python reading in one line multiple types for a calculator
- → How do I properly pass an argument to a function
- → Accessing Websql database with Qt
- → Using Mysql C API for c++ codes
- → How do I set constants at run-time in a c++ header file, imported through Cython?
Ad