本文整理汇总了C++中PreparedStatement::setBoolean方法的典型用法代码示例。如果您正苦于以下问题:C++ PreparedStatement::setBoolean方法的具体用法?C++ PreparedStatement::setBoolean怎么用?C++ PreparedStatement::setBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PreparedStatement
的用法示例。
在下文中一共展示了PreparedStatement::setBoolean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateFilterBlack
void ConfigConnector::updateFilterBlack(bool enable) {
Connection conn = _pool->getConnection();
PreparedStatement stmt = conn->prepareStatement("UPDATE `config_resource` SET `value` = ? WHERE `cid` = '1'");
stmt->setBoolean(1, enable);
stmt->execute();
_pool->returnConnection(conn);
}
示例2: nuodb_statement_bind
int nuodb_statement_bind(struct nuodb *db, struct nuodb_statement *st,
struct nuodb_value parameters[]) {
PreparedStatement *stmt = reinterpret_cast<PreparedStatement *>(st);
try {
int parameterCount = stmt->getParameterMetaData()->getParameterCount();
for (int i=0; i < parameterCount; ++i) {
int parameterIndex = i+1;
switch (parameters[i].vt) {
case NUODB_TYPE_NULL:
stmt->setNull(parameterIndex, NUOSQL_NULL);
break;
case NUODB_TYPE_INT64:
stmt->setLong(parameterIndex, parameters[i].i64);
break;
case NUODB_TYPE_FLOAT64: {
union {
int64_t i64;
double float64;
} value = { parameters[i].i64 };
stmt->setDouble(parameterIndex, value.float64);
break;
}
case NUODB_TYPE_BOOL:
stmt->setBoolean(parameterIndex, !!parameters[i].i64);
break;
case NUODB_TYPE_STRING: {
size_t length = parameters[i].i32;
const char *s = reinterpret_cast<const char*>(parameters[i].i64);
// Extra conversion due to missing length param in the setString API
const std::string str(s, length);
stmt->setString(parameterIndex, str.c_str());
break;
}
case NUODB_TYPE_BYTES: {
int length = parameters[i].i32;
const unsigned char *bytes = reinterpret_cast<const unsigned char*>(parameters[i].i64);
stmt->setBytes(parameterIndex, length, bytes);
break;
}
case NUODB_TYPE_TIME: {
int64_t seconds = parameters[i].i64;
int32_t nanos = parameters[i].i32;
SqlTimestamp ts(seconds, nanos);
stmt->setTimestamp(parameterIndex, &ts);
break;
}
}
}
return 0;
} catch (SQLException &e) {
return setError(db, e);
}
}
示例3: DBwrite
int PhoneCall::DBwrite(Connection *sqlCon)
{
if (!sqlCon || !id)
return -1;
PreparedStatement *pstmt = sqlCon->prepareStatement(
"UPDATE calls SET phone=(?), client=(?), translator=(?), client_country=(?), translator_country=(?), lang=(?), price=(?), start_time=(?), accounted=(?), cost=(?), error=(?), request_time=(?), confirm_time=(?), accepted=(?) WHERE id=(?)");
pstmt->setInt(1, true);
pstmt->setInt(2, client);
pstmt->setInt(3, translator);
pstmt->setString(4, ((PhoneCall *)this)->getClientCountry().c_str());
pstmt->setString(5, ((PhoneCall *)this)->getTranslatorCountry().c_str());
pstmt->setString(6, translateLang.c_str());
pstmt->setInt(7, price);
char time[512];
strftime(time, 512, SQLTIME_FMT, localtime(&start_time));
if (start_time)
pstmt->setDateTime(8, time);
else
pstmt->setNull(8, 0);
pstmt->setInt(9, getAccountedTime());
pstmt->setInt(10, cost);
pstmt->setInt(11, getState() == ERROR);
strftime(time, 512, SQLTIME_FMT, localtime(&request_time));
if (request_time)
pstmt->setString(12, time);
else
pstmt->setNull(12, 0);
strftime(time, 512, SQLTIME_FMT, localtime(&confirm_time));
if (confirm_time)
pstmt->setDateTime(13, time);
else
pstmt->setNull(13, 0);
pstmt->setBoolean(14, accepted);
pstmt->setInt(15, id);
int ret;
try {
ret = pstmt->executeUpdate();
} catch (SQLException &ex) {
log(LOG_ERROR, "[%s] MySQL error(%d): %s", __func__, ex.getErrorCode(), ex.what());
delete pstmt;
return 0;
}
delete pstmt;
return ret == 1;
}