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

Function tbl_select

lib_acl_cpp/samples/db/pgsql_pool/main.cpp:82–155  ·  view source on GitHub ↗

��ѯ������

Source from the content-addressed store, hash-verified

80
81// ��ѯ������
82static int tbl_select(acl::db_handle& db, int n)
83{
84 acl::query query;
85 query.create_sql("select * from group_tbl where group_name=:group"
86 " and uvip_tbl=:test")
87 .set_format("group", "group:%d", n)
88 .set_format("test", "test");
89
90 if (db.exec_select(query) == false)
91 {
92 printf("select sql error\r\n");
93 return (-1);
94 }
95
96 printf("\r\n---------------------------------------------------\r\n");
97
98 // �г���ѯ�������һ
99 const acl::db_rows* result = db.get_result();
100 if (result)
101 {
102 const std::vector<acl::db_row*>& rows = result->get_rows();
103 for (size_t i = 0; i < rows.size(); i++)
104 {
105 if (n > 100)
106 continue;
107 const acl::db_row* row = rows[i];
108 for (size_t j = 0; j < row->length(); j++)
109 printf("%s, ", (*row)[j]);
110 printf("\r\n");
111 }
112 }
113
114 // �г���ѯ���������
115 for (size_t i = 0; i < db.length(); i++)
116 {
117 if (n > 100)
118 continue;
119 const acl::db_row* row = db[i];
120
121 // ȡ�����м�¼��ij���ֶε�ֵ
122 const char* ptr = (*row)["group_name"];
123 if (ptr == NULL)
124 {
125 printf("error, no group name\r\n");
126 continue;
127 }
128 printf("group_name=%s: ", ptr);
129 for (size_t j = 0; j < row->length(); j++)
130 printf("%s, ", (*row)[j]);
131 printf("\r\n");
132 }
133
134 // �г���ѯ���������
135 const std::vector<acl::db_row*>* rows = db.get_rows();
136 if (rows)
137 {
138 std::vector<acl::db_row*>::const_iterator cit = rows->begin();
139 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…