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

Function tbl_select

lib_acl_cpp/samples/sqlite/sqlite.cpp:70–125  ·  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='���-%d' and uvip_tbl='test'";
74
75 acl::string sql;
76 sql.format(sql_fmt, n);
77
78 if (db.sql_select(sql.c_str()) == false)
79 {
80 printf("select sql error\r\n");
81 return (-1);
82 }
83
84 // �г���ѯ�������һ
85 const acl::db_rows* result = db.get_result();
86 if (result)
87 {
88 const std::vector<acl::db_row*>& rows = result->get_rows();
89 for (size_t i = 0; i < rows.size(); i++)
90 {
91 if (n >= 5)
92 continue;
93 const acl::db_row* row = rows[i];
94 for (size_t j = 0; j < row->length(); j++)
95 printf("%s, ", (*row)[j]);
96 printf("\r\n");
97 }
98 }
99
100 // �г���ѯ���������
101 for (size_t i = 0; i < db.length(); i++)
102 {
103 if (n >= 5)
104 continue;
105 const acl::db_row* row = db[i];
106
107 // ȡ�����м�¼��ij���ֶε�ֵ
108 const char* ptr = (*row)["group_name"];
109 if (ptr == NULL)
110 {
111 printf(("error, no group name\r\n"));
112 continue;
113 }
114 printf("group_name=%s: ", ptr);
115 for (size_t j = 0; j < row->length(); j++)
116 printf("%s, ", (*row)[j]);
117 printf("\r\n");
118 }
119
120 int ret = (int) db.length();
121
122 // �ͷŲ�ѯ���
123 db.free_result();
124 return (ret);
125}
126
127// ɾ��������

Callers 1

runMethod · 0.70

Calls 8

get_rowsMethod · 0.80
free_resultMethod · 0.80
formatMethod · 0.45
sql_selectMethod · 0.45
c_strMethod · 0.45
get_resultMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…