Answer the question
In order to leave comments, you need to log in
Why is it not getting data from another database?
I decided to try to use several databases, looked at the docks, took the config from there, but something doesn’t work.
doctrine:
dbal:
default_connection: default
connections:
default:
# configure these for your database server
url: '%env(DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
customer:
# configure these for your database server
url: '%env(DATABASE_CUSTOMER_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
Main:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: Main
customer:
connection: customer
mappings:
Customer:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: Customer
$this->getDoctrine()->getRepository(User::class, 'customer')->findAll();
Answer the question
In order to leave comments, you need to log in
In short, an error in namespaces, I had the same ones, I made different namespaces right away, everything became normal.
Reading the documentation: https://symfony.com/doc/current/doctrine/multiple_...
$entityManager = $this->getDoctrine()->getManager('default');
$customerEntityManager = $this->getDoctrine()->getManager('customer');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question