[odb-users] Help, problem in mysql

Boris Kolpackov boris at codesynthesis.com
Tue Mar 5 09:39:58 EST 2013


Hi,

staywild <staywild at foxmail.com> writes:

> Here I use the struct tm from <time.h> in CI try to map this date type
> to datetime in MySQL database, while encountered a gcc compiling failure.
> 
> #pragma db type("datetime") null
> struct tm finishedtime;

You will need to provide a value_traits specialization for tm that
maps it to/from the MySQL date-time representation (struct MYSQL_TIME).
The following blog post has detailed instructions on how to do this
(see the "Simple Value Types" section):

http://www.codesynthesis.com/~boris/blog/2012/10/16/custom-cxx-to-database-type-mapping-in-odb/

Alternatively, you may want to consider using a higher level date-time
representation, for example, the date-time library from Boost for which
ODB provides built-in support (see Section 21.5, "Date Time Library"
in the ODB manual).

Boris



More information about the odb-users mailing list