Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you store a paragraph in a database?

i am building a site, that includes the user submitting comments. Now, want to save the different comments.. i read a bit about Linq to SQL and ADO.. they all talk about storing small bits of information like names, emails, passwords etc. But whats the most efficient way to save messages (which will be incorporated to a page like in youtube) at the end?

like image 670
Dmitry Makovetskiyd Avatar asked Feb 25 '23 08:02

Dmitry Makovetskiyd


2 Answers

I think comments on a webpage still count as "small bits". Just make sure your database field has enough space (nvarchar(MAX) if supported, otherwise text or ntext, depending on your database of choice)

I don't think you need to start considering other methods of accessing data unless you have dozens of kilobytes of data per object, or a very large number of objects per page.

like image 192
Matti Virkkunen Avatar answered Feb 26 '23 20:02

Matti Virkkunen


Exactly the same way. You also want to html encode your message before you insert it into a database to avoid unwanted sql injections. Linq doesn't have such problems since it uses parameters to insert your text.

You should prefer paramater based insertion of text over embeded sql + encoding.

like image 33
Stanislav Ageev Avatar answered Feb 26 '23 20:02

Stanislav Ageev