Answer the question
In order to leave comments, you need to log in
How to configure the connection string to the database?
In my case ..
There is a name for the database inside the schema name. I'm using postgres!
The default schema is 'public' where tables are created when cli-config.php is run.
I can't find how to set the string to the schema I need and not the default 'public' ..
db-config.php:
<?php
return [
"dbname"=>"dbname",
"user"=>"postgres",
"password"=>"******",
"host"=>"localhost",
"driver"=>"pdo_pgsql"
];
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
$dbParams = include 'db-config.php';
// Creating database schema according to entities
// Docs reference below
// https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/tools.html
// https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/configuration.html
$config = Setup::createAnnotationMetadataConfiguration(array("../../entities"),true);
$entityManager = EntityManager::create($dbParams, $config);
return ConsoleRunner::createHelperSet($entityManager);
Answer the question
In order to leave comments, you need to log in
You can edit the postgres user so that it works by default in the desired schema:
alter user имя_пользователя set search_path = схема
Schemas are an additional level of ordering entities.
Options to choose from: specify the scheme in the names of objects in queries (usually) or change the search_path to the required one.
This is why the schema name is an attribute in the annotation of the table itself, not the connection string.
https://www.doctrine-project.org/projects/doctrine...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question