Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3918

How to use entity with DBAL sqlsrv for easybundle admin

$
0
0

Hello I have 2 databases connexion in my symfony and I want use an Entity and repository for simplify and finality use a EasyBundleAdmin, thanks advance

DBAL config :

doctrine:    dbal:    default_connection:       web    connections:       web:          driver: sqlsrv          dbname:           WEBSITE_DBF          user:             '%env(resolve:DB_USER)%'          password:         '%env(resolve:DB_PASSWORD)%'          host:             '%env(resolve:DB_HOSTNAME)%'          charset: UTF-8       account:          driver: sqlsrv          dbname:           ACCOUNT_DBF          user:             '%env(resolve:DB_USER)%'          password:         '%env(resolve:DB_PASSWORD)%'          host:             '%env(resolve:DB_HOSTNAME)%'          charset: UTF-8orm:    auto_generate_proxy_classes: true    naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware    auto_mapping: true    mappings:        App:            is_bundle: false            type: annotation            dir: '%kernel.project_dir%/src/Entity'            prefix: 'App\Entity'            alias: App

Entity account:

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/** * @ORM\Entity(repositoryClass="App\Repository\AccountRepository") */class Account{    /**     * @ORM\Id()     * @ORM\Column(type="string")     */    private $account;    private $result;    public function __construct()    {        $connection = $this->getDoctrine()->getConnection('account');        $result = $connection->fetchAll('SELECT * FROM ACCOUNT_TBL');        $this->result = $result;    }    public function getAccount(): ?string    {        return $this->account;    }}

EasyAdmin config:

easy_admin:   entities:       - App\Entity\Account

error obtain is

An exception has been thrown during the rendering of a template ("An exception occurred while executing 'SELECT DISTINCT a0_.account AS account_0, a0_.account AS account_1 FROM account a0_ ORDER BY a0_.account DESC OFFSET 0 ROWS FETCH NEXT 15 ROWS ONLY':

because it's connect at default (website and not accounct connection) and my table is account_tbl and not account

I would like create entity for different connection for use asy admin bundle with DBAL thanks


Viewing all articles
Browse latest Browse all 3918

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>