1 | #if __has_include(<mysql.h>) |
---|---|
2 | #include <mysql.h> |
3 | #else |
4 | #include <mysql/mysql.h> |
5 | #endif |
6 | |
7 | #include <mysqlxx/Connection.h> |
8 | #include <mysqlxx/StoreQueryResult.h> |
9 | |
10 | |
11 | namespace mysqlxx |
12 | { |
13 | |
14 | StoreQueryResult::StoreQueryResult(MYSQL_RES * res_, Connection * conn_, const Query * query_) : ResultBase(res_, conn_, query_) |
15 | { |
16 | UInt64 rows = mysql_num_rows(res); |
17 | UInt32 fields = getNumFields(); |
18 | reserve(rows); |
19 | lengths.resize(rows * fields); |
20 | |
21 | for (UInt64 i = 0; MYSQL_ROW row = mysql_fetch_row(res); ++i) |
22 | { |
23 | MYSQL_LENGTHS lengths_for_row = mysql_fetch_lengths(res); |
24 | memcpy(&lengths[i * fields], lengths_for_row, sizeof(lengths[0]) * fields); |
25 | |
26 | push_back(Row(row, this, &lengths[i * fields])); |
27 | } |
28 | checkError(conn->getDriver()); |
29 | } |
30 | |
31 | } |
32 |