Here is the code:
$conn = new PDO('mysql:host=localhost;dbname=locadora','root','');
$resul = $conn->query("SELECT * FROM usuario");
echo "<pre>";
$resul = $resul->fetchAll();
?>
And the output looks like this:
array(2) {
[0]=>
array(8) {
["id"]=>
string(1) "1"
[0]=>
string(1) "1"
["id_cli"]=>
string(1) "1"
[1]=>
string(1) "1"
["user"]=>
string(12) "david.santos"
[2]=>
string(12) "david.santos"
["senha"]=>
string(60) "I82A1G"
[3]=>
string(60) "I82A1G"
}
[1]=>
array(8) {
["id"]=>
string(1) "2"
[0]=>
string(1) "2"
["id_cli"]=>
string(1) "2"
[1]=>
string(1) "2"
["user"]=>
string(12) "joao.batista"
[2]=>
string(12) "joao.batista"
["senha"]=>
string(6) "senha"
[3]=>
string(6) "senha"
}
}
Doubt is because the data is duplicate? I know that if I use "fetch (PDO :: FETCH_ASSOC)" the problem will be solved but I would like to understand why this is happening