LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   how can I access blob in mysql by C ? (http://www.linuxquestions.org/questions/programming-9/how-can-i-access-blob-in-mysql-by-c-755898/)

twwwater 09-17-2009 09:23 AM

how can I access blob in mysql by C ?
 
Hi, all

well, I was working on a problem, and I googled for almost 2 or 3 days so far, but got nothing. en........., I want to stored the pictures into mysql, and I just do not know how to access this bother me so much's "blob". and I wonder anyone if could be kind enough to help me !

anyone could tell me how can I access the blob by pure C code or it would be much better if anyone could show me the source code or example ?

thanks in advanced !!!

twwwater (taowuwen@gmail.com)

Guttorm 09-17-2009 10:34 AM

Hi

The easiest way is to treat them as regular strings. Just use mysql_real_escape_string to escape the characters like '\0' and you'll be fine.

http://dev.mysql.com/doc/refman/5.0/...pe-string.html

But if the images are very big, the queries can be too long. I think the only way is to use prepared statements and mysql_stmt_send_long_data. This page has an example:

http://dev.mysql.com/doc/refman/5.0/...long-data.html

twwwater 09-17-2009 09:17 PM

hehe!!! Thank you so much !!! it works ! at first something went wrong, and I got some errors, but finally, it worked !!! thank you once again!


All times are GMT -5. The time now is 01:14 AM.