I'm running a SELECT in the database through a function and returning the result as a multidimensional array, where each primary index refers to a record, and the secondary indexes are the bank fields with the values.
Below is the function return assembly:
$resultado = $this->conn->query($sql);
if ($resultado->rowCount() > 0) {
foreach($resultado as $chave => $valor){
$retorno[$chave] = $valor;
}
return $retorno;
} else {
return false;
}
When I get the return and execute a var_dump()
, the result looks like this:
array (size=3)
0 =>
array (size=4)
'usu_id' => string '1' (length=1)
0 => string '1' (length=1)
'usu_nome' => string 'Administrador' (length=13)
1 => string 'Administrador' (length=13)
The second dimension of the array is creating two indexes for the return: "0" and "usu_id", as well as "1" and "usu_name".
Is that correct? Does PHP act anyway or is there an error in the way I'm mounting the return array?