What kind of Mysql data should I use to register random numbers for requests

-1

Colleagues.

I am creating a registry where a request number is generated for the user. The structure is as follows:

    $prefixo = "CAD";
    $idCadastro = mysqli_insert_id($this->conexao);
    $rand = rand(100,999);
    $ano = date("y"); 
    $CAD = $prefixo."-".$idCadastro.$rand."/".$ano;

It returns this way:

  

CAD-11231/17

In Mysql I am using the Varchar data type (255), however I am in doubt whether I should use this data type. The IdCadastro field is self-incrementing, so you do not run the risk of duplicating. Is there any other more specific data type for this or is Varchar (255) fine?

    
asked by anonymous 15.02.2017 / 00:51

1 answer

0

You already answer your question in the answer itself.

In this case, I see no reason to save numeric data converted to "text". If you do not want to limit this numeric range so much, I recommend saving these numbers as integers.

For more information I suggest reviewing the MysSQL documentation at the link below: link

    
15.02.2017 / 01:15