-
Notifications
You must be signed in to change notification settings - Fork 1
add work with database #1
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
Conversation
|
@fey Коль, посмотри плиз, норм ли такой подход. Будем ли класс для сущности создавать, или ассоциативный массив пусть остается? Если норм, уже урок на основе этого напишу |
public/index.php
Outdated
| $filePath = implode('/', [dirname(__DIR__), 'init.sql']); | ||
| $initSql = file_get_contents($filePath); | ||
| $conn->exec($initSql); | ||
| $carRepository = new CarRepository($conn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Malcom1986 репозиторий лучше положить в контейнер, как ниже.
$container->set(CarRepository::Class, function ()
Ключем будет имя класса, а отдаваться будет обьект уже сконфигурированный. По идее аналогично должен передаваться Репозиторию коннекшон. Тк у нас есть конейнер зависимостей. мы можем его использовать.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну или в качестве ключа можно просто строку использовать, но тогда это будет строка, а не константа класса)
Я думаю можно ассоц массив использовать |
|
Сделал инжекцию репозитория через контейнер. Заодно сущность на класс переписал |
|
поправишь эту штуку? Undefined variable '$router'. |
No description provided.