Having trouble with PDO queries (Notice: Undefined index)
PHP Snippet 1:
$row = $resultBySQL->fetchAll(PDO::FETCH_ASSOC);
PHP Snippet 2:
//notice the 'fetch' in place of 'fetchAll'
while ( $row = $resultBySQL->fetch(PDO::FETCH_ASSOC); )
{
$user = new User();
$user->setUsername($row['username']);
//...
}
PHP Snippet 3:
$rows = $resultBySQL->fetchAll(PDO::FETCH_ASSOC);
foreach( $rows as $row )
{
$user = new User();
$user->setUsername($row['username']);
//...
}