Returns TRUE on success.
Returns FALSE on failure. Use pbms_errno() and pbms_error() to retrieve error details.
/* * This is an example of a callback to stream a file from the PBMS daemon. * In this case the caller_data is a pointer to a file handle. */ size_t file_callback(void *caller_data, const char *buffer, size_t size, pbms_bool reset) { int *fh = (int*) caller_data; if (reset) { lseek(fh, 0, SEEK_SET); } if (size) { size = write(fh, buffer, size); } return size; } main () { PBMS pbms; int fh; pbms_library_init(false); pbms = pbms_connect("localhost", 8080, "aDatabase"); // Fetch the BLOB back, 'name' is a LONGBLOB column. mysql_query(mysql, "select name from bobtest where id = 1"); results = mysql_store_result(mysql); record = mysql_fetch_row(result); // Open a file into which the BLOB will be streamed. fh = open("myblob.jpg", O_WRONLY | O_CREAT | O_TRUNC, 0000777); pbms_get_data_cb(pbms, record[0], file_callback, &fh)); pbms_close(pbms); pbms_library_end(); }