Reduce character size with PHP

Asked

Viewed 241 times

0

I need to decrease the character size from 17000 to 4000 with php, how to do this compression, and then be able to decode again to the normal string size, I cannot lose characters after decoding again.

  • 2

    Cannot guarantee this compressive capacity for all strings.

  • I think you need to be clearer than that. What is your purpose?

  • Save a 17000-character string to an Oracle database that only accepts 4000 characters.

  • No Oracle field accepts a string of this size, if accepted I want to know which hehehe

  • An image, already in blob, just because even in blob, it is not possible to save more than 4000 characters in a literal string.

  • 3

    I recommend not saving images inside the bank, as explained by Luiz at: http://answall.com/a/12717/3635

  • I have a suggestion, but it’s just a suggestion, something you can do or not do. You can have 5 columns of 4k size each, thus supporting up to 20k. If you don’t want to do this save the text in an argument and save the path to the file.

  • I don’t understand Bruno Costa.

  • 1

    Separate text into 4000-sized blocks and save to separate columns.

  • I already thought about it, just because the size of the photo is not fixed, it is difficult to measure each new photo how many columns the photo will need, is not a fixed size, complicating even more the situation.

  • So the only solution you have left is to save the text as binary in BLOB or BFILE format. Alias type CLOB also supports strings larger than 4k

  • Blob field does not accept strings larger than 4000 characters.

  • 2

    But is it an image or a string that you want to save? And blob field does not accept a giant volume of data?

  • It’s an image, just because images need to be converted before they’re inserted into a database, I’m converting them to binary.

  • 2

    @ROBERTOALBINOJUNIOR From the Oracle documentation: "The maximum size of a LOB is 128 terabytes." I would say that your file fits into a BLOB yes. Source: https://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT513

Show 10 more comments

1 answer

0

Just don’t save files directly to the bank! Instead just save the file to a folder and its path/name in the database.

Simple as that, never save.

  • I will need to change all my system logic to later be able to recover these images, as I am migrating the system from MYSQL to Oracle, I do not want to mecher logic but only fix this fault.

  • 2

    @ROBERTOALBINOJUNIOR In fact it would be the best solution to save the image somewhere, and refer only the way in the comic, think about this possibility.... If you don’t do it now, in the future they’ll have a headache to refactor the code anyway, if not you, the next responsible for the system.... better fix now since they are migrating Mysql pro Oracle, than to postpone

  • Imagine the inconvenience I save on a server and for some reason this server gives up and I lose everything? I’ll need to back up these images myself, it’s a very big hassle.

  • But if you think about server failure, your database will be saved where?

  • It already has backup.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.