Hey guys. I'm writing myself an online toolbox (for my code snippets). I have a "Snippets" table. My question is this. Would you save the snippet source in a Text column or would you have the snippet saved to a text file and the Snippet entry would reference the file name?
Depends what you want to do with it. Having the text file is handy as you can download it, although you can create one on the fly. Not sure if it makes too much difference. However, if you have a search facility on the code itself, then you'd be better to place it into a text field. Files may be vulnerable to overwriting if you upload same names. If you're only displaying one snippet at a time on a page and you're not going to have millions of records, perhaps it won't make much difference to the load time. You can test the time to load for both methods with microtime(). Just a few thoughts. I'm sure other contributors with have preferences and good reasons for them.
OK, perhaps it would be an idea un unsolve this and maybe attract a few more viewpoints. I don't think I gave you much sound advice, a few ramblings and half thoughts really. The beauty of the db only solution is that everything is "self contained", having data strewn over a db and a file system can have its difficulties.
If you do go down the link-to-file system, ensure that you only store the filename as you may wish to change the name of the directory at some point. In which case, you'd have to update every record in the DB. Also, before accepting a new file upload, check for the existence of file with that name and give yourself a prompt to confirm an overwrite or to be able to rename it before it's stored. Can be a pain.
Hi, I am a newbie in developing a website. i have tried to connect using mysqli conncetion
Here is my simple code.
// db.php code
//$con = mysqli_connect("localhost","root","","bakery"); ...
If you're in one of those predicaments where cls.__private attributes just aren't enough since they can easily be accessed through inst._cls__private, and you need something a little more secure, here's ...