ID on a table is altered

-1

I have a table in mysql, which when inserted from PHP alters the logical order of the ID:

"INSERT INTO 'persona' ('id_persona', 'nombre_contacto', 'apellido_contacto',
                           'telefono_persona', 'email_persona', 'documento',
                           'horaEntrada', 'horaSalida', 'usuario', 'password',
                           'tipo_documento', 'id_ciudad_persona', 'id_estado_persona', 'empresa_per',
                           'id_tipoUsuario', 'id_usuario_punto', 'dependencia_persona')
                            VALUES (NULL, '$nombre ', '$apellido', NULL, NULL, '$documentoIdentidad',
                                    NULL, NULL, NULL, NULL, NULL, NULL, NULL, '$id_empresa', '5', NULL, '$tipoDependencia')"

----------- Insert from PHPmyAdmin behaves well, following the logical order.

00000000113             
00000000114             
00000000115          
00000000116       

----------- Alterates when done from PHP

00000000118  
00000000120
00000000122        

What is the reason for this anomaly?

    
asked by jecorrales 28.09.2017 в 22:11
source

1 answer

1

If your ID that is the primary key is to increase it is not necessary that you send it as null, you do not even need to mention it, only one bit of your code:

"INSERT INTO 'persona' ('nombre_contacto', 'apellido_contacto',
                           'telefono_persona', 'email_persona', 'documento',
                           'horaEntrada', 'horaSalida', 'usuario', 'password',
                           'tipo_documento', 'id_ciudad_persona', 'id_estado_persona', 'empresa_per',
                           'id_tipoUsuario', 'id_usuario_punto', 'dependencia_persona')
                            VALUES ('$nombre ', '$apellido', NULL, NULL, '$documentoIdentidad',
                                    NULL, NULL, NULL, NULL, NULL, NULL, NULL, '$id_empresa', '5', NULL, '$tipoDependencia')"
    
answered by 28.09.2017 / 22:26
source