MCPcopy Create free account
hub / github.com/acl-dev/acl / tbl_select

Function tbl_select

lib_acl_cpp/samples/db/mysql_pool/main.cpp:135–208  ·  view source on GitHub ↗

��ѯ������

Source from the content-addressed store, hash-verified

133
134// ��ѯ������
135static int tbl_select(acl::db_handle& db, int n)
136{
137 acl::query query;
138 query.create_sql("select * from group_tbl where group_name=:group"
139 " and uvip_tbl=:test")
140 .set_format("group", "group:%d", n)
141 .set_format("test", "test");
142
143 if (db.exec_select(query) == false)
144 {
145 printf("select sql error\r\n");
146 return (-1);
147 }
148
149 printf("\r\n---------------------------------------------------\r\n");
150
151 // �г���ѯ�������һ
152 const acl::db_rows* result = db.get_result();
153 if (result)
154 {
155 const std::vector<acl::db_row*>& rows = result->get_rows();
156 for (size_t i = 0; i < rows.size(); i++)
157 {
158 if (n > 100)
159 continue;
160 const acl::db_row* row = rows[i];
161 for (size_t j = 0; j < row->length(); j++)
162 printf("%s, ", (*row)[j]);
163 printf("\r\n");
164 }
165 }
166
167 // �г���ѯ���������
168 for (size_t i = 0; i < db.length(); i++)
169 {
170 if (n > 100)
171 continue;
172 const acl::db_row* row = db[i];
173
174 // ȡ�����м�¼��ij���ֶε�ֵ
175 const char* ptr = (*row)["group_name"];
176 if (ptr == NULL)
177 {
178 printf("error, no group name\r\n");
179 continue;
180 }
181 printf("group_name=%s: ", ptr);
182 for (size_t j = 0; j < row->length(); j++)
183 printf("%s, ", (*row)[j]);
184 printf("\r\n");
185 }
186
187 // �г���ѯ���������
188 const std::vector<acl::db_row*>* rows = db.get_rows();
189 if (rows)
190 {
191 std::vector<acl::db_row*>::const_iterator cit = rows->begin();
192 for (; cit != rows->end(); cit++)

Callers 1

runMethod · 0.70

Calls 8

exec_selectMethod · 0.80
get_rowsMethod · 0.80
beginMethod · 0.80
free_resultMethod · 0.80
get_resultMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…