To return all the items in a query sql use the method fetchAll () , because if you only put fetch () is to return only one item of the result, usually in search of data of 1 customer, data of a purchase, etc, ie to bring a collection
:
Modified code:
function recuperaPaises()
{
//Função que pega os países do banco e jogam no array de países da classe
$conexao = new DB;
$conexao=$conexao->getConnection();
$rs = $conexao->prepare("SELECT * FROM paises");
if ($rs->execute()){
$row = $rs->fetchAll(PDO::FETCH_OBJ);
return $row;
}
return null;
}
I made a modification if it did not return result return null
out of this method call if the return information can be better worked.