#
#
# artur #2014-11-09 07:20:23
MySQL
# artur #, 2014-11-09 07:20:23

How to store large formatted text in the database?

Hello!
There was a need to store a large formatted text (contents of invoices) in the table, the table is very simple:
id (int) | description (?)
There is no way to format the contents of description when outputting. I want to store immediately with html tags.
Entering information into this table will be a separate function that will receive only variables WITHOUT any tags, and so on.
What data type to choose? How safe and correct is it?
PS: the need appeared in the process of writing an online store in which products and categories will be constantly deleted / renamed and it is necessary to issue correct information about old orders. Those. in descriptionthe names of goods, their quantities, amounts at the time of payment for the order will be included, and all this will be arranged in the form of a "light" table, and saved under a unique order ID.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Philipp, 2014-11-09
@zoonman

LONGTEXT, with a competent approach, it is absolutely safe, because you create the content.
As for the correct question, it’s a difficult one, because. depends on the task.
Usually, such things are generated on the fly and the composition of the order is stored. All marketers like to ask what was in trend last May. Well, all sorts of ABC-analyses are needed, etc., sales reports with cuts.

V
Vladimir Korshunov, 2014-11-09
@BekoBou

I once saved the basket at the time of ordering. The payment was made, the data was recorded (price, quantity, name, order number, delivery, etc.).
If a relational database, then transferred the data to separate 2 tables (the first one stores information about the order, and the second one stores items from the basket). Then I switched to MongoDB and this is one record in the collection.
Why so - sometimes the design (both appearance and behavior) changes, it needs to be redone, and in this case it's easier to just render the page. For example, for writing, for displaying, for API and for printing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question