Added get_last_insert_rowid() method to PreparedStatement.

This commit is contained in:
Relintai 2024-12-11 13:27:57 +01:00
parent a52e1f168a
commit c9ca35accd
5 changed files with 13 additions and 0 deletions

View File

@ -93,6 +93,8 @@ void PreparedStatement::_bind_methods() {
ClassDB::bind_method(D_METHOD("column_count"), &PreparedStatement::column_count);
ClassDB::bind_method(D_METHOD("get_last_insert_rowid"), &PreparedStatement::get_last_insert_rowid);
// Control
ClassDB::bind_method(D_METHOD("prepare"), &PreparedStatement::prepare);

View File

@ -100,6 +100,8 @@ public:
virtual int column_count() = 0;
virtual int get_last_insert_rowid() = 0;
// Control
virtual Error prepare() = 0;
virtual Error step() = 0;

View File

@ -41,6 +41,7 @@ class QueryResult : public Reference {
public:
virtual bool next_row();
virtual String get_cell(const int index);
virtual bool get_cell_bool(const int index);
virtual int get_cell_int(const int index);

View File

@ -438,6 +438,12 @@ int SQLite3PreparedStatement::column_count() {
return sqlite3_column_count(_prepared_statement);
}
int SQLite3PreparedStatement::get_last_insert_rowid() {
ERR_FAIL_COND_V(!_connection.is_valid(), 0);
return sqlite3_last_insert_rowid(_connection->conn);
}
// Control
Error SQLite3PreparedStatement::prepare() {
ERR_FAIL_COND_V(!_connection.is_valid(), FAILED);

View File

@ -84,6 +84,8 @@ public:
virtual int column_count();
virtual int get_last_insert_rowid();
// Control
virtual Error prepare();
virtual Error step();