diff --git a/mx_mysql.c b/mx_mysql.c index df20452..e7f9a50 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -426,6 +426,20 @@ static int mx__mysql_stmt_affected_rows(struct mx_mysql_stmt *stmt, unsigned lon return 0; } +static int mx__mysql_stmt_insert_id(struct mx_mysql_stmt *stmt, unsigned long long *count) +{ + my_ulonglong c; + + mx_assert_return_minus_errno(stmt, EINVAL); + mx_assert_return_minus_errno(stmt->stmt, EBADF); + + c = mysql_stmt_insert_id(stmt->stmt); + + *count = (unsigned long long)c; + + return 0; +} + static int mx__mysql_stmt_close(struct mx_mysql_stmt *stmt) { my_bool res; @@ -847,6 +861,10 @@ int mx_mysql_statement_execute(struct mx_mysql_stmt *stmt, unsigned long long *c return 0; } +int mx_mysql_statement_insert_id(struct mx_mysql_stmt *stmt, unsigned long long int *id) { + return mx__mysql_stmt_insert_id(stmt, id); +} + int mx_mysql_statement_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count) { return mx__mysql_stmt_affected_rows(stmt, count); } diff --git a/mx_mysql.h b/mx_mysql.h index c07096e..e994bf7 100644 --- a/mx_mysql.h +++ b/mx_mysql.h @@ -155,6 +155,7 @@ int mx_mysql_statement_init(struct mx_mysql *mysql, struct mx_mysql_stmt **stmt) int mx_mysql_statement_prepare(struct mx_mysql_stmt *stmt, char *statement); int mx_mysql_statement_execute(struct mx_mysql_stmt *stmt, unsigned long long *count); +int mx_mysql_statement_insert_id(struct mx_mysql_stmt *stmt, unsigned long long int *id); int mx_mysql_statement_affected_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count); int mx_mysql_statement_num_rows(struct mx_mysql_stmt *stmt, unsigned long long int *count);