A
A
Artem00712017-10-03 11:00:49
PHP
Artem0071, 2017-10-03 11:00:49

Is there a set of rules for adding data to a database?

Using Prepared Queries (PDO)
I'm getting different types of data. Is there a "table" of how different types need to be handled?
For example, when adding email or links to a site, I use a function in PHP (filter_var),
For plain text - "strip_tags"
What else needs to be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2017-10-03
@Artem0071

No, when adding to the database , there is no "set of rules".
Moreover, all your existing processings have nothing to do with adding to the database.
The database does not care what data to store.
The only rule that is really needed for the database, you already apply - you use prepared questions.
If we are not talking about the database, but about filtering data "in general", then it is impossible to answer this question. Just like it is impossible to answer the question, "Is there a list of diseases that I need to be treated for?". It all depends on what you are sick with. If it is important for you to check links, then check links. Not important? Don't check. Can't skip tags? Use strip_tags. Need to skip tags? Don't use strip_tags. And so on - it all depends on the task. There is no universal rule or "set of rules", a kind of magic wand that you waved once and forgot about data validation, and cannot be.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question