source code:
<?php
$dsn = 'mysql:dbname=oop;host=localhost;';
$user = 'admin';
$password = 'password';
try {
$pdo = new PDO($dsn, $user, $password);
} catch (PDOException $e)
{
echo 'Connection failed: ' . $e->getMessage();
}
$stmt = $pdo->prepare("select * from be_users");
$stmt->execute();
echo "<pre>";
print_r($stmt->fetchAll());
echo "</pre>";
?>
result:
Array
(
[0] => Array
(
[username] => tom
[0] => tom
[email] => dsfde@gmail.com
[1] => dsfde@gmail.com
)
[1] => Array
(
[username] => tom3
[0] => tom3
[email] => sdfsdfs@gmail.com
[1] => sdfsdfs@gmail.com
)
...
Question:
Why the result is not like this:
Array
(
[0] => Array
(
[username] => tom
[email] => dsfde@gmail.com
)
[1] => Array
(
[username] => tom3
[email] => sdfsdfs@gmail.com
)