If you are not familiar with Prepared Statements on MySQL, take
a look at the source code comments and explanations in the file
sql::PreparedStatement is created by
passing an SQL query to
sql::PreparedStatement is derived from
sql::Statement, you will feel familiar
with the API once you have learned how to use (simple)
sql::Statement). For example,
the syntax for fetching results is identical.
// ... sql::Connection *con; sql::PreparedStatement *prep_stmt // ... prep_stmt = con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)"); prep_stmt->setInt(1, 1); prep_stmt->setString(2, "a"); prep_stmt->execute(); prep_stmt->setInt(1, 2); prep_stmt->setString(2, "b"); prep_stmt->execute(); delete prep_stmt; delete con;
As usual, you must free
sql::Connection objects explicitly.