FSQLiteQueryResult USQLiteDatabase::GetDataBP(const FSQLiteDatabaseReference& DataSource, TArray<FString> Fields, FSQLiteQueryFinalizedQuery Query, int32 MaxResults, int32 ResultOffset) { FSQLiteQueryResult result; ////////////////////////////////////////////////////////////////////////// // Check input validness. ////////////////////////////////////////////////////////////////////////// if (DataSource.Tables.Num() == 0) { LOGSQLITE(Error, TEXT("The query needs at least one table name!")); result.Success = false; result.ErrorMessage = TEXT("No table given"); return result; } if (Fields.Num() == 0) { LOGSQLITE(Error, TEXT("The query needs fields! You can use * to get all fields.")); result.Success = false; result.ErrorMessage = TEXT("No fields given"); return result; } FString constructedQuery = ConstructQuery(DataSource.Tables, Fields, Query, MaxResults, ResultOffset); return GetData(DataSource.DatabaseName, constructedQuery); }
FuzzyQuery::FuzzyQuery(const TermPtr& term) { ConstructQuery(term, defaultMinSimilarity(), defaultPrefixLength); }
FuzzyQuery::FuzzyQuery(const TermPtr& term, double minimumSimilarity) { ConstructQuery(term, minimumSimilarity, defaultPrefixLength); }
FuzzyQuery::FuzzyQuery(const TermPtr& term, double minimumSimilarity, int32_t prefixLength) { ConstructQuery(term, minimumSimilarity, prefixLength); }
bool USQLiteDatabase::GetDataIntoObjectBP(const FSQLiteDatabaseReference& DataSource, TArray<FString> Fields, FSQLiteQueryFinalizedQuery Query, UObject* ObjectToPopulate) { ////////////////////////////////////////////////////////////////////////// // Check input validness. ////////////////////////////////////////////////////////////////////////// if (ObjectToPopulate == NULL) { LOGSQLITE(Error, TEXT("ObjectToPopulate needs to be set to get any results!")); return false; } if (DataSource.Tables.Num() == 0) { LOGSQLITE(Error, TEXT("The query needs the table name!")); return false; } if (Fields.Num() == 0) { LOGSQLITE(Error, TEXT("The query needs fields! You may use * to get all fields.")); return false; } ////////////////////////////////////////////////////////////////////////// // Validate the database ////////////////////////////////////////////////////////////////////////// if (!IsDatabaseRegistered(DataSource.DatabaseName) || !IsValidDatabase(Databases[DataSource.DatabaseName], true)) { LOGSQLITE(Error, TEXT("Unable to get data to object, database validation failed!")); return false; } ////////////////////////////////////////////////////////////////////////// // Get the results ////////////////////////////////////////////////////////////////////////// FString constructedQuery = ConstructQuery(DataSource.Tables, Fields, Query, 1, 0); SQLiteQueryResult queryResult = RunQueryAndGetResults(DataSource.DatabaseName, constructedQuery); if (queryResult.Success && queryResult.Results.Num() > 0) { AssignResultsToObjectProperties(queryResult.Results[0], ObjectToPopulate); return true; } else if (!queryResult.Success) { LOGSQLITE(Error, *FString::Printf(TEXT("Query resulted in an error: '%s'"), *queryResult.ErrorMessage)); return false; } else if (queryResult.Results.Num() == 0) { LOGSQLITE(Error, TEXT("Query returned zero rows, no data to assign to object properties.")); return false; } return false; }