C++ 如何绑定SOCI查询的输出?
以下代码:生成错误消息,如下所示:C++ 如何绑定SOCI查询的输出?,c++,boost,soci,C++,Boost,Soci,以下代码:生成错误消息,如下所示: bool-UACmUsers::GetUser(int-userid){ 会话sql(dbU::Connection()); sql您的字符串不是标准字符串。wxString可能在SOCI中不支持转换 要么进行转换,要么扩展类型转换。可能不是最有效的,但有效: namespace soci { template <> struct type_conversion<wxString> { typedef std::
bool-UACmUsers::GetUser(int-userid){
会话sql(dbU::Connection());
sql您的字符串不是标准字符串。wxString可能在SOCI中不支持转换
要么进行转换,要么扩展类型转换。可能不是最有效的,但有效:
namespace soci {
template <> struct type_conversion<wxString> {
typedef std::string base_type;
static void from_base(base_type const& s, indicator ind, wxString& ws) {
if (ind == i_null)
ws.clear();
else
ws = s;
}
static void to_base(const wxString& ws, base_type& s, indicator& ind) {
s = ws.ToStdString();
ind = i_ok;
}
};
} // namespace soci
或在后续运行中:
Table already exists
Duplicate entry '11' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=11, :name="one", :pwd="bar".
Duplicate entry '12' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=12, :name="two", :pwd="gjb".
Duplicate entry '13' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=13, :name="three", :pwd="guerr".
Duplicate entry '14' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=14, :name="four", :pwd="sbhe".
Duplicate entry '15' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=15, :name="five", :pwd="svir".
last: SELECT userid, username, password FROM uac_users WHERE userid = ":user"
12 "two" "gjb"
表中包含
笔记
在示例中,当insert语句抛出时,似乎存在内存泄漏。我想这需要向上游报告
在数据库中存储密码之前,请三思。正确的安全经验规则:
- 永远不要存储密码。句号
- 总是存储散列
- 不要使用快速哈希或非加密强哈希(不要使用MD5或SHA废话)
- 始终为每个用户使用一个
您的字符串不是标准字符串。wxString可能在SOCI中不支持转换
要么进行转换,要么扩展类型转换。可能不是最有效的,但有效:
namespace soci {
template <> struct type_conversion<wxString> {
typedef std::string base_type;
static void from_base(base_type const& s, indicator ind, wxString& ws) {
if (ind == i_null)
ws.clear();
else
ws = s;
}
static void to_base(const wxString& ws, base_type& s, indicator& ind) {
s = ws.ToStdString();
ind = i_ok;
}
};
} // namespace soci
或在后续运行中:
Table already exists
Duplicate entry '11' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=11, :name="one", :pwd="bar".
Duplicate entry '12' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=12, :name="two", :pwd="gjb".
Duplicate entry '13' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=13, :name="three", :pwd="guerr".
Duplicate entry '14' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=14, :name="four", :pwd="sbhe".
Duplicate entry '15' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=15, :name="five", :pwd="svir".
last: SELECT userid, username, password FROM uac_users WHERE userid = ":user"
12 "two" "gjb"
表中包含
笔记
在示例中,当insert语句抛出时,似乎存在内存泄漏。我想这需要向上游报告
在数据库中存储密码之前,请三思。正确的安全经验规则:
- 永远不要存储密码。句号
- 总是存储散列
- 不要使用快速哈希或非加密强哈希(不要使用MD5或SHA废话)
- 始终为每个用户使用一个
希望这有帮助。不过,请务必阅读结尾处的注释。希望这有帮助。不过,请务必阅读结尾处的注释。
Table already exists
Duplicate entry '11' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=11, :name="one", :pwd="bar".
Duplicate entry '12' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=12, :name="two", :pwd="gjb".
Duplicate entry '13' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=13, :name="three", :pwd="guerr".
Duplicate entry '14' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=14, :name="four", :pwd="sbhe".
Duplicate entry '15' for key 'PRIMARY' while executing "insert into uac_users values (:id, :name, :pwd)" with :id=15, :name="five", :pwd="svir".
last: SELECT userid, username, password FROM uac_users WHERE userid = ":user"
12 "two" "gjb"