POO list records

Asked

Viewed 115 times

2

Hey, guys, which of these ways is best to list the bank records? The first is the structured way and the second is the object oriented is not? Thanks.

First:

$sql = $usuario -> listar();

foreach($sql AS $registro)
{
    echo $registro['nome'];
}

According to:

$sql = $usuario -> listar();

foreach($sql AS $registro)
{
    $usuario -> setNome($registro['nome']);
    echo $usuario -> getNome();
}
  • 3

    No context doesn’t get any better. And in PHP, the functions and methods that have the 2 syntaxes are equivalent (and can be mixed in the same chunk of code, including). In fact, in PHP object orientation is irrelevant, and does not add significant functionality. Everything can be done in any of the 2 paradigms.

  • 1

    1) I don’t understand the second example, you use setNome and then getNome, I don’t see the point in that - unless there’s another context. 2) I think your doubt is more related to DAO that POO.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.