DatabaseResultSPtr CDatabaseConnectionMySql::DoExecuteSelect( const String & query, DatabaseValuedObjectInfosPtrArray & infos ) { MYSQL_STMT * statement = mysql_stmt_init( _connection ); MySQLCheck( mysql_stmt_prepare( statement, query.c_str(), uint32_t( query.size() ) ), INFO_MYSQL_STATEMENT_PREPARATION, EDatabaseExceptionCodes_StatementError, _connection ); auto ret = ExecuteSelect( statement, infos ); mysql_stmt_close( statement ); return ret; }
void ExecuteStatement(MyDB & db, std::unique_ptr<ISQLStatement> const & statement, CSVPrinter & printer) { switch (statement->GetType()) { case SQLStatementType::CREATE: { if (db.ExecuteCreate(statement)) std::cout << "OK" << std::endl; break; } case SQLStatementType::INSERT: { size_t rows = db.ExecuteUpdate(statement); std::cout << "OK " << rows << std::endl; break; } case SQLStatementType::SELECT: { ExecuteSelect(db, statement, printer); break; } default: std::cout << "Unknown sql statement." << std::endl; } }