95 sqlite3_prepare_v2(m_conn, sql.c_str(), -1, &ppStmt, 0);
99 status = sqlite3_step(ppStmt);
100 if(status == SQLITE_DONE)
105 if(status == SQLITE_ROW)
110 int ncolumns = sqlite3_column_count(ppStmt);
112 for(i=0; i<ncolumns; i++)
115 unsigned long field_len = sqlite3_column_bytes(ppStmt,i);
117 const char* col_name = sqlite3_column_name(ppStmt,i);
118 char column_name[255];
119 strcpy(column_name,col_name);
120 int type = sqlite3_column_type(ppStmt,i);
121 if(type == SQLITE_BLOB)
123 new_record =
new char[field_len];
124 char* col_result = (
char*)sqlite3_column_blob(ppStmt,i);
125 memcpy(new_record,col_result,field_len);
127 else if (type != SQLITE_NULL)
129 new_record =
new char[field_len+1];
130 char* col_result = (
char*)sqlite3_column_text(ppStmt,i);
131 strcpy(new_record,col_result);
137 (*dbrec)[column_name] = new_record;
140 records.push_back(dbrec);
146 cerr <<
"SQLITE query error: " << zErrMsg << endl;
150 sqlite3_free(zErrMsg);
151 sqlite3_finalize(ppStmt);
155 return records.size();