Project

General

Profile

Wt::Dbo BYTEA and BLOB type

Added by Freddy Martinez Garcia almost 10 years ago

Hy guys...

how can I use BYTEA and BLOB type with Wt::Dbo??? cause I need to save some files into my db using the ORM of the framework...

is that possible ??

regards


Replies (3)

RE: Wt::Dbo BYTEA and BLOB type - Added by Wim Dumon almost 10 years ago

Hello Freddy,

I believe an std::vector is saved as a blob type in the database. You can write your own traits classes to define how your raw data structures are to be stored in the database, if Wt::Dbo does not know them. There are a few included in Dbo by default, see Wt/Dbo/StdSqlTraits and its .C file.

Wim.

RE: Wt::Dbo BYTEA and BLOB type - Added by Freddy Martinez Garcia almost 10 years ago

 You can write your own traits classes to define how your raw data structures are to be stored in the database, if Wt::Dbo does not know them.

There is some example about it ??

I was looking for something like WFile or something like that and aI didn't find nothing. Lokking for more deep, I have found Wt::Dbo::backend::Postgres::blobType()

this method return a char*, which should be the file content, but, How can I define a field like BLOB?? Using a std::vector could be, but I must use bind() function ?? how can I do that ???

that is my doubt my friend !!!

I'm new with witty...

regards

RE: Wt::Dbo BYTEA and BLOB type - Added by Wim Dumon almost 10 years ago

Hello Freddy,

Take a look at the documentation of Wt/Dbo/SqlTraits, and at Wt/Dbo/StdSqlTraits and Wt/Dbo/StdSqlTraits.C, and at WtSqlTraits and WtSqlTraits.C in the Wt source code for example implementations of traits classes. To map your own data structures on Dbo types, you can write a traits class. To store a file as a blob in the database, you can either store the file's contents in a std::vector (for which the traits class already exists), or write one of your own.

Best regards,

Wim.

    (1-3/3)