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

Function tbl_select

lib_acl_cpp/samples/db/mysql_query/main.cpp:150–223  ·  view source on GitHub ↗

��ѯ������

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 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…