Is it possible to place an HMTL file inside the database?

3

Is it possible to save an HTML file to a BLOB column within the database and then display it as part of the page in PHP?

Why do this: It's more for a learning experiment to compare if it gets better than a include on the page.

    
asked by anonymous 26.10.2018 / 23:22

1 answer

4

The file itself is not possible, after all file is a concept of the operating system file system, but text that is HTML is entirely possible. It does not even have to be BLOB . It can be this type of column, but it can be TEXT or VARCHAR and even CHAR although probably quite inadequate. You do not need to have a file to generate the content, what will be delivered needs to be a text recognized as HTML, just this.

Of course, it is the function of your application to properly deliver to the HTTP server so that this HTML is sent to the client when it has a request. Your application can take this HTML from anywhere, can compose several parts, you can do whatever you want. If you can compose consistently it is a powerful tool to give flexibility in the result.

You should avoid abuse, have to take care of security, may not be the one that gives more performance, may not be the most suitable for what you need, but these are other issues.

I can already say that it does not get better than include , just make use of a database if necessary.

    
27.10.2018 / 00:06