By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,721 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,721 IT Pros & Developers. It's quick & easy.

how to use convert_uuencode()

P: n/a
On www.php.net, on the page for convert_uuencode(), someone posted
this comment:

>>>>>>>>>>>> This function can be useful if you wish to store files in a MySQL
database, it will save any problems with obscure binary data breaking
the queries.

just remember to convery-uudecode before you try to use the data
again.

(A common example of something that uses this system, would be email
attachments)>>>>>>>>>>>>

If I understand this right, before you insert any binary data into a
MySql database, you should first hit it with convert_uuencode() ?
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
lawrence <lk******@geocities.com> wrote:
>>>>>>>>>>>>> This function can be useful if you wish to store files in a MySQL
database, it will save any problems with obscure binary data breaking
the queries.

just remember to convery-uudecode before you try to use the data
again.

(A common example of something that uses this system, would be email
attachments)>>>>>>>>>>>>>

If I understand this right, before you insert any binary data into a
MySql database, you should first hit it with convert_uuencode() ?


While the above note is technicaly correct, storing uuencoded data has a
big impact: 37% size increase. base64 would be better is this aspect
(35%) (according to 'man uuencode'). Also the data is totally useless
until fully decoded again...

Pro is that the data can be stored in a textonly field, with mysql there
is almost no difference between text and blob fields.

I would suggest using mysql_real_escape_string() and storing it in a
blob.

--

Daniel Tryba

Jul 17 '05 #2

P: n/a
On 30 Sep 2004 09:15:29 -0700, lk******@geocities.com (lawrence) wrote:
On www.php.net, on the page for convert_uuencode(), someone posted
this comment:
>>>>>>>>>>>>>This function can be useful if you wish to store files in a MySQL
database, it will save any problems with obscure binary data breaking
the queries.

just remember to convery-uudecode before you try to use the data
again.

(A common example of something that uses this system, would be email
attachments)>>>>>>>>>>>>>


If I understand this right, before you insert any binary data into a
MySql database, you should first hit it with convert_uuencode() ?


No, MySQL is perfectly capable of storing binary data without needing
encoding, using the BLOB types. uuencoding it adds overhead in both processing
time and space required.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #3

P: n/a
Daniel Tryba <ne****************@canopus.nl> wrote in message news:<cj**********@news.tue.nl>...
lawrence <lk******@geocities.com> wrote:
>>>>>>>>>>>>>> This function can be useful if you wish to store files in a MySQL
database, it will save any problems with obscure binary data breaking
the queries.

just remember to convery-uudecode before you try to use the data
again.

(A common example of something that uses this system, would be email
attachments)
>>>>>>>>>>>>>>

If I understand this right, before you insert any binary data into a
MySql database, you should first hit it with convert_uuencode() ?


While the above note is technicaly correct, storing uuencoded data has a
big impact: 37% size increase. base64 would be better is this aspect
(35%) (according to 'man uuencode'). Also the data is totally useless
until fully decoded again...

Pro is that the data can be stored in a textonly field, with mysql there
is almost no difference between text and blob fields.


Wow! That means a lot to me. I've written a datastore abstraction
layer so that my code never knows what datastore it is dealing with -
MySql, Postgre, or an XML flat file. I worried about how the different
databases handle binary data - a problem I hadn't tackled yet. From
the sounds of it, convert_uuencode() allows any binary data to be
stored in the text fields of any database. Assuming I'm willing to pay
the size penalty, this sounds like this could make it rather easy to
standardize the way my abstraction layer handles binary data. If I
understand you right, I could use convert_uuencode() to store binary
data in an XML flat file? That's exciting.

I would suggest using mysql_real_escape_string() and storing it in a
blob.


Why would you use mysql_real_escape_string() on binary data? Is that
to protect yourself in case some user is trying to sneak in non-binary
data?
Jul 17 '05 #4

P: n/a
lawrence <lk******@geocities.com> wrote:
If I
understand you right, I could use convert_uuencode() to store binary
data in an XML flat file? That's exciting.


AFAIK XML has no problems with binary data, just put it in a CDATA block
(but then you have to escape the end of CDATA sequence)... but the
answer is yes.
I would suggest using mysql_real_escape_string() and storing it in a
blob.


Why would you use mysql_real_escape_string() on binary data? Is that
to protect yourself in case some user is trying to sneak in non-binary
data?


Atleast single quotes ans slashes need to be escaped, alternatively
addslashes() does the job. But mysql_real_escape_string claims to be
more intelligent.

--

Daniel Tryba

Jul 17 '05 #5

P: n/a
Andy Hassall <an**@andyh.co.uk> wrote in message news:<qv********************************@4ax.com>. ..
On 30 Sep 2004 09:15:29 -0700, lk******@geocities.com (lawrence) wrote:
On www.php.net, on the page for convert_uuencode(), someone posted
this comment:.....

If I understand this right, before you insert any binary data into a
MySql database, you should first hit it with convert_uuencode() ?


No, MySQL is perfectly capable of storing binary data without needing
encoding, using the BLOB types. uuencoding it adds overhead in both processing
time and space required.


I get it now. You use this function if you want to store binary data
in a text field.
Jul 17 '05 #6

P: n/a
Daniel Tryba <ne****************@canopus.nl> wrote in message news:<cj**********@news.tue.nl>...
lawrence <lk******@geocities.com> wrote:
If I
understand you right, I could use convert_uuencode() to store binary
data in an XML flat file? That's exciting.


AFAIK XML has no problems with binary data, just put it in a CDATA block
(but then you have to escape the end of CDATA sequence)... but the
answer is yes.


Good point.
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.