我需要跨数据库关系,我有qazxsw poi但由于映射问题我无法得到我想要的东西。这是我的情况
read about this
我的学说.yaml
namespace App\Entity\Utility;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Crm\User;
/**
* Description of Test
*
* @ORM\Table(name="fgel_utility.fgel_test")
* @ORM\Entity(repositoryClass="App\Repository\Utility\TestRepository")
*/
class Test
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
*
* @var User
*
* @ORM\ManyToOne(targetEntity="App\Entity\Crm\User")
* @ORM\JoinColumn(name="user_cod", referencedColumnName="AUCUT")
*/
protected $user = null;
public function getId()
{
return $this->id;
}
public function getUser(): User
{
return $this->user;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function setUser(User $user)
{
$this->user = $utente;
return $this;
}
}
namespace App\Entity\Crm;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @ORM\Table(name="crm.USER")
* @ORM\Entity(repositoryClass="App\Repository\FintelGasDati\AnuteRepository")
*/
class User
{
/**
*
* @ORM\Id
* @ORM\Column(name="AUCUT", type="integer", nullable=false)
*/
protected $codiceCliente;
# SOME CODE
}
所以他们共享相同的连接(但不同的em)。连接的用户具有读/写两个数据库的权限(但只能将模式更改为fgel_utility数据库。两个数据库都存储在SQL Server 2008中。当我试着执行时
doctrine:
orm:
default_entity_manager: default
entity_managers:
#################################
# Update schema only with this em
#################################
default:
connection: mssql_1
mappings:
Utility:
type: "annotation"
# The directory for entity (relative to bundle path)
dir: '%kernel.project_dir%/src/Entity/Utility'
prefix: 'App\Entity\Utility'
alias: Utility
mssql_crm:
connection: mssql_1
mappings:
Crm:
type: "annotation"
# The directory for entity (relative to bundle path)
dir: '%kernel.project_dir%/src/Entity/Crm'
prefix: 'App\Entity\Crm'
alias: Crm
我收到这个错误
在链配置的命名空间App \ Entity \ Utility,FOS \ UserBundle \ Model中找不到类“App \ Entity \ Crm \ User”
根据这个php bin/console doctrine:schema:update --dump-sql
交叉数据库连接不同的实体管理器(相同的连接)不受支持。