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

Function tbl_select

lib_acl_cpp/samples/mysql/mysql.cpp:70–143  ·  view source on GitHub ↗

��ѯ������

Source from the content-addressed store, hash-verified

68
69// ��ѯ������
70static int tbl_select(acl::db_handle& db, int n)
71{
72 const char* sql_fmt = "select * from group_tbl where"
73 " group_name='%s-%d' and uvip_tbl='test'";
74
75 acl::string sql;
76 sql.format(sql_fmt,
77 acl::strconv(__pre, strlen(__pre), "gbk", "utf8").c_str(), n);
78
79 if (db.sql_select(sql.c_str()) == false) {
80 printf("select sql error\r\n");
81 return -1;
82 }
83
84 printf("\r\n---------------------------------------------------\r\n");
85
86 // �г���ѯ�������һ
87 const acl::db_rows* result = db.get_result();
88 if (result) {
89 const std::vector<acl::db_row*>& rows = result->get_rows();
90 for (size_t i = 0; i < rows.size(); i++) {
91 if (n > 100) {
92 continue;
93 }
94 const acl::db_row* row = rows[i];
95 for (size_t j = 0; j < row->length(); j++) {
96 printf("%s, ", (*row)[j]);
97 }
98 printf("\r\n");
99 }
100 }
101
102 // �г���ѯ���������
103 for (size_t i = 0; i < db.length(); i++) {
104 if (n > 100) {
105 continue;
106 }
107 const acl::db_row* row = db[i];
108
109 // ȡ�����м�¼��ij���ֶε�ֵ
110 const char* ptr = (*row)["group_name"];
111 if (ptr == NULL) {
112 printf("error, no group name\r\n");
113 continue;
114 }
115 printf("group_name=%s: ", ptr);
116 for (size_t j = 0; j < row->length(); j++) {
117 printf("%s, ", (*row)[j]);
118 }
119 printf("\r\n");
120 }
121
122 // �г���ѯ���������
123 const std::vector<acl::db_row*>* rows = db.get_rows();
124 if (rows) {
125 std::vector<acl::db_row*>::const_iterator cit = rows->begin();
126 for (; cit != rows->end(); cit++) {
127 if (n > 100) {

Callers 1

mainFunction · 0.70

Calls 11

strconvFunction · 0.85
get_rowsMethod · 0.80
beginMethod · 0.80
free_resultMethod · 0.80
formatMethod · 0.45
c_strMethod · 0.45
sql_selectMethod · 0.45
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…