Using MySQL C API - check success of inserting rows using prepared statements

后端 未结 1 1443
抹茶落季
抹茶落季 2021-01-27 04:05

I\'m beginning to learn how to use the MySQL C API and have encountered prepared statements. I haven\'t used these before in other languages so it\'s all new to me.

I\'v

相关标签:
1条回答
  • 2021-01-27 04:27

    You already have the code in

    if(mysql_stmt_execute(stmt) != 0) {
            printf("Unable to create new session: Could not execute statement\n");
            return NULL;
    }
    

    If that fails, you didn't insert any rows. The docs contain a full example

    You can also use mysql_stmt_affected_rows() after a successful mysql_stmt_execute() to find out how many rows were insterted/updated/deleted.

    0 讨论(0)
提交回复
热议问题