Fiz um code para verificar se o usuário e email já são existentes, mas quando o usuário existe ele retorna o seguinte erro:
Fatal error: Fatal error: Cannot use object of type stdClass as array
$query_check_user_name = $this->db->prepare('SELECT username, mail FROM users WHERE username= :user_name OR
mail = :user_email');
$query_check_user_name->bindValue(':user_name', $user_name, PDO::PARAM_STR);
$query_check_user_name->bindValue(':user_email', $user_email, PDO::PARAM_STR);
$query_check_user_name->execute();
$result = $query_check_user_name->fetchAll();
if (count($result) > 0) {
for ($i = 0; $i < count($result); $i++) {
$this->errors[] = ($result[$i]['user_name'] == $user_name) ? MESSAGE_USERNAME_EXISTS : MESSAGE_EMAIL_ALREADY_EXISTS;
}
} else {
}
for
para iterar comarrays
, principalmente com aquelecount($result)
sendo chamado a cada verificação de for :)