Answer the question
In order to leave comments, you need to log in
Article preview implementation?
Hello. It was necessary to implement a preview (partial display of the article). It can be compared with Habr: on the main page there is a somewhat truncated article; when you click on the link - the full version! How to design an implementation in SQL?
At the moment there are three ideas:
Answer the question
In order to leave comments, you need to log in
If the size of the database is not critical, then 2, but without a connection (that is, in the first cell, the announcement, in the second, the entire article).
If the time it takes to pull the necessary articles from the database and cut them in half is not critical, then 3.
Personally, I use the 2nd option and do not feel remorse.
What nonsense?! Of course, two fields are enough: article_anounce and article_text.
I see I am not fully understood, so I will describe in more detail.
- We need a table with fields: id and anounce.
- We display blocks of text with this information on the main page. Click to open the article with the required id.
- We take the entire article from a file called .php
Advantages:
- We do not load it with heavy DBMS queries. There are fewer requests.
- Opcacher itself caches articles. Without any dances with a tambourine.
The most productive option would be to store the article in a file, and store only a link to the file in the database.
And for the first point, try this:
SUBSTRING(`text`, 1, (INSTR(`text`, "[habracut]")-1))
Two fields. In one - only what is up to the mark of the kata. The second is the entire article (as well as what is before the kata mark, and after).
Of course, data duplication is obtained. But if CPU is more important to you than hard disk space, then why not?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question