Is it a good practice to have the same name with the column name of the bank?

4

Let's say I have a input text de name="txtnome" , is it a good practice to have a column of the same name as this input in my table?

Being that I'm using PDO for CRUD

$st =$this->db->prepare("UPDATE $tabela SET yxtnome=:txtnome WHERE id=:id");
$st->execute(array(
   ":id"=> $_POST["id"],
   ":txtnome" => $_POST["txtnome"]
 ));
    
asked by anonymous 11.05.2016 / 04:33

1 answer

5
___ erkimt ___ Is it a good practice to have the same name with the column name of the bank? ______ qstntxt ___

Let's say I have a txt , is it a good practice to have a column of the same name as this UPDATE $tabela in my table?

Being that I'm using PDO for CRUD

%pre%     
______ ___ azszpr127885

It can be said that it is. If it does not cause any problems, it's good practice.

But like all "good practice", it is only valid when the person knows what he's doing. When a person does not understand why it is being adopted, it is only repeating what others have said to her do, will always be a bad practice. Even if it's right, if you hit it by coincidence, it's a bad practice.

The only good practice in fact is to understand what you're doing, deeply study the mechanism you are using and analyzing the specific situation to determine whether or not to adopt a particular procedure that the real situation.

Is the purpose of the database column to store exactly what is in the page form? So it seems to be ok. Now if the column holds a data that has a relation with this page field, but this happens only by chance, if this column can have data coming from other points of the application, ie if the relation is indirect, then this can change of figure. Or not, after all there are names that are very common.

Some people find that using the %code% prefix is not recommended. It's unnecessary. This is considered Hungarian notation and discouraged to be superfluous and possibly harmful when you need to for some reason exchange the data type.

It may be that the application architecture, which I do not know, may have a specific need that makes this a bad practice. But I can not say.

But notice that this is all very conceptual. Technically there is nothing that prevents or causes trouble. And maybe that's the real question.

While %code% can be a bad practice depending on where this variable comes from. It would be ask to suffer a potentially devastating attack on the database. But this is not the focus of the question.

    
___
11.05.2016 / 05:08