Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hw12 #1128

Open
wants to merge 1 commit into
base: ASyrovatkin/main
Choose a base branch
from
Open

hw12 #1128

wants to merge 1 commit into from

Conversation

elexandr
Copy link

No description provided.

$this->findAllStatement = $pdo->prepare('SELECT * FROM products');
}

public function insert(array $productArr): Product
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сюда передается сущность, а не массив, мэппер не фабрика.


public function findAll(): array
{
$this->findAllStatement->setFetchMode(PDO::FETCH_CLASS, Product::class);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такая реализация ставит нейминг аттрибутов сущности в прямое соотвевтствие с полями таблицы. Хрупко. Теряется смысл дата мэппера. Необходимо вытаскивать сырые данные и через конструктор или рефлексию (в случае приватных полей) явно создавать сущности.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants