Hi,
the problem is, that there is already a similar operator for std::set<T>
in the tntdb namespace, which is prefered. So your operator is not used
at all.
The other operator fills a list of host variables. Calling
result.set("bar", foobar)
results in
result.set("bar0", "FOO");
result.set("bar1", "BAR");
When thinking again I'm not sure, if that was such a good idea to define
it that way. The same is achived by:
result.set("bar", foobar.begin(), foobar.end());
I think I should really remove those operators for containers. It is
irritating.
I guess no one has used that feature and those who have, will get a
compile error, so that nothing unexpected will happen, when I remove those.
Any opinions?
Tommi
Am 07.07.2015 um 12:29 schrieb Matthias Kraß:
Hi All,
I’ve tried to overload the operator described in
http://www.tntnet.org/howto/tntdb.html at the part “Using own types”,
so that I can write a std::set<std::string> in a mysql Database.
Therefore I implemented this:
void operator <<(tntdb::Hostvar& hv, const std::set<std::string>& lists) {
std::ostringstream s;
for(auto element: lists) {
s << element << ";";
}
hv.set(s.str());
}
This should define how a set should be written in the Database. I’ve
tested it with this example:
std::set<std::string> foobar ={"FOO","BAR"};
tntdb::Statement result = DB->connection.prepare(
"CREATE TABLE IF NOT EXISTS foo(bar TEXT)");
result.execute();
result = DB->connection.prepare(
"INSERT INTO foo(bar) values (:bar)");
result.set("bar",foobar);
result.execute();
So after this the table in the Database should look like :
+-------------+
| bar |
+-------------+
| FOO;BAR; |
+-------------+
But the database entry looks like:
+-------------+
| bar |
+-------------+
| NULL |
+-------------+
Can somebody reproduce this misbehaviour?
Kind regards,
Matthias Kraß
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general