В приведенном ниже примере используется одна таблица базы данных (животные), которая содержит три столбца (имя, описание, фотография).
Если моя база данных содержит две таблицы (1.animals, 2.Cities),каждый со своими столбцами (имя, описание, фотография), как я могу спросить, например.«имена городов», который расположен в столбце 1 таблицы 2., в сочетании с «описанием животных», расположенным в столбце 2 таблицы 1, чтобы создать объект с этими «значениями».
, ссылаясь на это ..... (char *) sqlite3_column_text (compiledStatement, 1) ....
Спасибо.
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
const char *sqlStatement = "select * from animals";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString *aDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
NSString *aImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];
// Create a new animal object with the data from the database
Animal *animal = [[Animal alloc] initWithName:aName description:aDescription url:aImageUrl];