On Jun 29, 2008, at 11:23 PM, Soul Boy wrote:
> you need to access the database twice
No, actually, you don't. The second parameter to the sql_create_x
sets the first N members of the SSQLS as key fields, which are used in
building the UPDATE statement.
Thus, if I have a table with a single unique key field (call it "id"),
then I can update the row where id=42 like this:
sql_create_X(foo, 1, 0,
mysqlpp::sql_int, id,
other, fields,
go, here)
foo new_row(5000, init, other, parameters);
query.update(foo(42), new_row);
query.execute();
This builds a query of the form: "UPDATE foo SET (id=5000,...) WHERE
(id=42)" This works because we said the first field of foo is the
unique key column, so we got a 1-parameter ctor taking
mysqlpp::sql_int. We passed a temporary foo to update(), with only
this first field set.