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

Function tbl_insert

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

���ӱ�����

Source from the content-addressed store, hash-verified

106
107// ���ӱ�����
108static bool tbl_insert(acl::db_handle& db, int n)
109{
110 if (db.begin_transaction() == false)
111 {
112 printf("begin transaction false: %s\r\n", db.get_error());
113 return false;
114 }
115
116 acl::query query;
117 query.create_sql("insert into group_tbl(group_name, uvip_tbl,"
118 " update_date) values(:group, :test, :date)")
119 .set_format("group", "group:%d", n)
120 .set_parameter("test", "test")
121 .set_date("date", time(NULL), "%Y-%m-%d");
122
123 if (db.exec_update(query) == false)
124 return (false);
125
126 if (db.commit() == false)
127 {
128 printf("commit error: %s\r\n", db.get_error());
129 return false;
130 }
131
132 const acl::db_rows* result = db.get_result();
133 if (result)
134 {
135 const std::vector<acl::db_row*>& rows = result->get_rows();
136 for (size_t i = 0; i < rows.size(); i++)
137 {
138 const acl::db_row* row = rows[i];
139 for (size_t j = 0; j < row->length(); j++)
140 printf("%s, ", (*row)[j]);
141 printf("\r\n");
142 }
143 }
144
145 db.free_result();
146 return (true);
147}
148
149// ��ѯ������
150static int tbl_select(acl::db_handle& db, int n)

Callers 1

mainFunction · 0.70

Calls 10

set_parameterMethod · 0.80
exec_updateMethod · 0.80
get_rowsMethod · 0.80
free_resultMethod · 0.80
begin_transactionMethod · 0.45
get_errorMethod · 0.45
commitMethod · 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…