Guest User

Untitled

a guest
Feb 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. function Query(const sql : string; const loop_name : string;
  2. const T : TTemplate) : Integer;
  3. var
  4. res : PMYSQL_RES;
  5. row : MYSQL_ROW;
  6. fields : PMYSQL_FIELD;
  7. it : TTemplate;
  8. index, field_count : integer;
  9. begin
  10. Query := 0;
  11. res := Query(PChar(sql), field_count);
  12. if res = nil then Exit;
  13. fields := mysql_fetch_fields(res);
  14.  
  15. LogInfo('SQL = ' + sql);
  16. LogInfo('Field count = ' + IntToStr(field_count));
  17.  
  18. row := mysql_fetch_row(res);
  19. while row <> nil do
  20. begin
  21. it := T.LoopIteration(loop_name);
  22.  
  23. for index := 0 to (field_count-1) do
  24. begin
  25. LogInfo(IntToStr(index) + '(' + fields[index].name + ') ="' + row[index] + '"');
  26. it.SetValue(fields[index].name, row[index]);
  27. end;
  28. Query := Query + 1;
  29. row := mysql_fetch_row(res);
  30. end;
  31.  
  32. CloseQuery(res);
  33. end;
Add Comment
Please, Sign In to add comment