All,

First of all, thanks to everyone(Sinisa, Opus) who gave input into the
resolution of my problem.  What I ended up doing was escaping any character
that would be interpreted as a special character in an STL string.  These
included ", \0, and '.  So, basically I armored the binary data and inserted
the object as a string into the BLOB field of my particular table.  This may
or may not be the best solution to the problem, but it is one that met my
needs.  And so, there you have it, one solution to inserting binary data
into a blob field using MySQL++.

Regards,

Thi

-----Original Message-----
From: Opus [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 22, 2002 3:14 PM
To: Thi Cao; MySQL
Subject: Re: Inserting a BLOB using MySQL++


Probably the best bet would be to write the individual attributes to
respective 
database columns.  It keeps a few things simpler.  It would also allow you
to 
update the database from multible sources (many threads, or many users on
the 
database).

Other wise, you would have to serialize the object to a binary object and
write 
that to the BLOB field.  When you imported it back, you would have to 
deserialize.  Some languages call this pickeling.  As I have not touched C++

code for a while, I'm not sure what classes are availible to do this for
you.

The BLOB way of doing it would force you read/write the entire thing
everytime 
you update the object, unless you are just using the database to store it
for 
backup.

-Opus

On 22 Apr 2002 at 8:21, Thi Cao wrote:

> All,
> 
> I created a C++ class containing a variety of member variables of varying
> types such as float, int, char *, etc.  If I instantiate an object of this
> class, how should I insert this object into my database table?  I can
> retrieve the individual members and insert them that way, but I feel it
> would be more efficient to insert the object as a BLOB, but I don't
exactly
> know how to do that.  Basically, I want to insert the object as is so that
I
> can retrieve it as is and not have to bother with calling the member
setting
> functions to populate the class members.  I looked at the MySQL++ example
> for loading a binary file, but am unsure how to apply that to my needs.  I
> also looked through the mail archives and was unsuccessful in finding a
> solution, so any assistance would be much appreciated.  Thanks in advance.
> 
> Regards,
> 
> Thi
> 


--Opus--

Government is not reason, it is not eloquence- it is force.
                            - George Washington

--------------------------------------------------------
Get added to my Humor list:
mailto:[EMAIL PROTECTED]?subject=ADD_HUMOR
Get added to my Neat list:
mailto:[EMAIL PROTECTED]?subject=ADD_NEAT
Get my PGP public key:
mailto:[EMAIL PROTECTED]?subject=PSEND&body=send%20PublicKEY.asc
Visit My Home Page:
http://value.net/~opus/



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to