how to use convert_uuencode()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lawrence

    how to use convert_uuencode()

    On www.php.net, on the page for convert_uuencod e(), someone posted
    this comment:

    [color=blue][color=green][color=darkred]
    >>>>>>>>>>>>>>> >[/color][/color][/color]
    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)[color=blue][color=green][color=darkred]
    >>>>>>>>>>>>>>> >[/color][/color][/color]


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

    #2
    Re: how to use convert_uuencod e()

    lawrence <lkrubner@geoci ties.com> wrote:[color=blue][color=green][color=darkred]
    >>>>>>>>>>>>>>> >>[/color][/color]
    > 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)[color=green][color=darkred]
    >>>>>>>>>>>>>>> >>[/color][/color]
    >
    >
    > If I understand this right, before you insert any binary data into a
    > MySql database, you should first hit it with convert_uuencod e() ?[/color]

    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_esca pe_string() and storing it in a
    blob.

    --

    Daniel Tryba

    Comment

    • Andy Hassall

      #3
      Re: how to use convert_uuencod e()

      On 30 Sep 2004 09:15:29 -0700, lkrubner@geocit ies.com (lawrence) wrote:
      [color=blue]
      >On www.php.net, on the page for convert_uuencod e(), someone posted
      >this comment:
      >[color=green][color=darkred]
      >>>>>>>>>>>>>>> >>[/color][/color]
      >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)[color=green][color=darkred]
      >>>>>>>>>>>>>>> >>[/color][/color]
      >
      >If I understand this right, before you insert any binary data into a
      >MySql database, you should first hit it with convert_uuencod e() ?[/color]

      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 / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
      <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

      Comment

      • lawrence

        #4
        Re: how to use convert_uuencod e()

        Daniel Tryba <news_comp.lang .php@canopus.nl > wrote in message news:<cjhfit$4e i$1@news.tue.nl >...[color=blue]
        > lawrence <lkrubner@geoci ties.com> wrote:[color=green][color=darkred]
        > >>>>>>>>>>>>>>> >>[/color]
        > > 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)[color=darkred]
        > >>>>>>>>>>>>>>> >>[/color]
        > >
        > >
        > > If I understand this right, before you insert any binary data into a
        > > MySql database, you should first hit it with convert_uuencod e() ?[/color]
        >
        > 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.[/color]

        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_uuencod e() 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_uuencod e() to store binary
        data in an XML flat file? That's exciting.



        [color=blue]
        > I would suggest using mysql_real_esca pe_string() and storing it in a
        > blob.[/color]

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

        Comment

        • Daniel Tryba

          #5
          Re: how to use convert_uuencod e()

          lawrence <lkrubner@geoci ties.com> wrote:[color=blue]
          > If I
          > understand you right, I could use convert_uuencod e() to store binary
          > data in an XML flat file? That's exciting.[/color]

          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.
          [color=blue][color=green]
          >> I would suggest using mysql_real_esca pe_string() and storing it in a
          >> blob.[/color]
          >
          > Why would you use mysql_real_esca pe_string() on binary data? Is that
          > to protect yourself in case some user is trying to sneak in non-binary
          > data?[/color]

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

          --

          Daniel Tryba

          Comment

          • lawrence

            #6
            Re: how to use convert_uuencod e()

            Andy Hassall <andy@andyh.co. uk> wrote in message news:<qvlol0tf3 90h00kolnkkcqgi tjo3rq2ukm@4ax. com>...[color=blue]
            > On 30 Sep 2004 09:15:29 -0700, lkrubner@geocit ies.com (lawrence) wrote:
            >[color=green]
            > >On www.php.net, on the page for convert_uuencod e(), 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_uuencod e() ?[/color]
            >
            > 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.[/color]

            I get it now. You use this function if you want to store binary data
            in a text field.

            Comment

            • lawrence

              #7
              Re: how to use convert_uuencod e()

              Daniel Tryba <news_comp.lang .php@canopus.nl > wrote in message news:<cji4v7$6q i$1@news.tue.nl >...[color=blue]
              > lawrence <lkrubner@geoci ties.com> wrote:[color=green]
              > > If I
              > > understand you right, I could use convert_uuencod e() to store binary
              > > data in an XML flat file? That's exciting.[/color]
              >
              > 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.[/color]

              Good point.

              Comment

              Working...