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

Method db_update

lib_acl_cpp/samples/check_trigger/db_store.cpp:70–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70bool db_store::db_update(const http_thread& http)
71{
72 // ��ȡ���ݿ�����
73 acl::db_handle* db = var_dbpool->peek();
74 if (db == NULL)
75 {
76 logger_error("peek db connect failed!");
77 return false;
78 }
79
80 // ���ȴ����ݿ�
81 if (db->open(var_cfg_dbcharset) == false)
82 {
83 logger_error("open db error, charset: %s",
84 var_cfg_dbcharset);
85 var_dbpool->put(db);
86 return false;
87 }
88
89 // ���������ٶ�
90 double speed = (http.length_ * 1000) / http.spent_http_;
91
92 acl::string sql;
93 sql.format("insert into http_tbl(addr, url, total_spent,"
94 " dns_spent, connect_spent, http_spent, length, speed,"
95 " success, currtime) values('%s', '%s', %.2f, %.2f, %.2f,"
96 " %.2f, %d, %.2f, '%s', CURRENT_TIMESTAMP)",
97 http.addr_, http.url_.c_str(), http.spent_total_,
98 http.spent_dns_, http.spent_connect_, http.spent_http_,
99 http.length_, speed, http.success_ ? "ok" : "error");
100
101 // �������ݿ���ֶ�
102 if (db->sql_update(sql.c_str()) == false)
103 logger_error("sql(%s) error", sql.c_str());
104 else
105 logger("sql: %s ok", sql.c_str());
106
107 // �黹���ݿ�����
108 var_dbpool->put(db);
109 return true;
110}

Callers 1

~http_threadMethod · 0.80

Calls 6

peekMethod · 0.45
openMethod · 0.45
putMethod · 0.45
formatMethod · 0.45
c_strMethod · 0.45
sql_updateMethod · 0.45

Tested by

no test coverage detected