1
Well I couldn’t find a better title for my case, I have the following function:
public function select_tokens() {
$sql = "SELECT * FROM `users`";
$select_tokens = Database::DB()->prepare($sql);
$select_tokens->execute();
$fetch = $select_tokens->fetchAll(PDO::FETCH_ASSOC);
foreach ($fetch as $token) {
$tokens[] = [
'user_token' => $token['user_token'],
'user_token2' => $token['user_token2']
];
}
return $tokens;
}
Look, I’m coming back $tokens
that in case I could use so:
$tk = $users->select_tokens();
And then pick up the index:
$tk['user_token'];
or
$tk['user_token2'];
But I don’t know why this error returns to me:
Notice: Undefined index: user_token
or
Notice: Undefined index: user_token2
Obs: I want to take all tokens
of all table users users
.
Yes, but he returns to me only
1
token in the case of the first ID, I want to catch the 10 it contains in the table. I tried this way.– Matheus Borjes
I edited the answer to show how to get everyone in one key
– Ricardo Moraleida
Show, it’s what I wanted, it worked. Thanks.
– Matheus Borjes