list Schet PortHandler getSchet sqlite3 db int idPort if dbManager NUL

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
list<Schet>* PortHandler::getSchet(sqlite3* db, int idPort)
{
if(dbManager == NULL) return NULL;
// Exec query to retrieve data
sqlite3_stmt* t_schet = dbManager->ExecQry(format(selectTSchet.c_str(),idPort).c_str(),db);
// Check if query were success
if((t_schet == NULL) || (sqlite3_column_count(t_schet) != 5)) return NULL;
list<Schet>* res_lst = new list<Schet>();
list<Schet>::iterator it = res_lst->begin();
while(sqlite3_step(ppVm)!=SQLITE_DONE)
{
Schet* schet = new Schet;
schet->IdSchet = sqlite3_column_int(t_schet, 0);
schet->IdFields = sqlite3_column_int(t_schet, 1);
schet->Serial = sqlite3_column_int(t_schet, 2);
schet->NeedSync = sqlite3_column_int(t_schet, 3);
schet->MinSync = sqlite3_column_int(t_schet, 4);
schet->MaxSync = sqlite3_column_int(t_schet, 5);
res_lst->insert(it++, *schet);
}
int rc=sqlite3_finalize(t_schet);
return res_lst;
}