CSS in DB

Hi all,

  How to put css file in MYSQL DB and retreive it in layouts/main.php page based on PK of that table in DB??

Don’t do it. MySQL is not a file storage system.

Maybe you could describe the problem at hand what makes you think using MySQL as file storage is the right thing™?

Best,

– David

Maybe because it allows people to edit the stylesheets ‘online’ ?

Lots of CMS’s does that, as does phpBB - nothing wrong with it.

I believe all you have to do is echo the contents of the css field in a css script block in the main layout.

Then you have to send all CSS for every request - instead of letting the browser cache CSS files. If you really want to serve CSS from DB, then you should create an action that renders what looks like CSS file content as output. Then you can link to that action as if it where a regular CSS file.

You are right (of course) - I am actually doing the same thing for my sitemap - that should work. :)