0
我在ZF2的學說中有2個連接,但我需要在兩個數據庫中加入連接。最大的問題是:是否可以在兩個不同數據庫和連接的表上執行連接?交叉數據庫加入原則
'connection' => array(
// Default DB connection
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'user' => 'root',
'port' => '3306',
'password' => '',
'dbname' => 'MYSQL_TEST',
'driverOptions' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
)
),
),
// Alternative DB connection
'orm_alternative' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOSqlsrv\Driver',
'params' => array(
'host' => 'localhost',
'user' => 'sa',
'port' => '',
'password' => 'test',
'dbname' => 'MSSQL_TEST',
),
),
),
實體MYSQL實例:
/**
* mysql_test
*
* @ORM\Table(name="mysql_table")
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
* @ORM\Entity(repositoryClass="MYSQL\Entity\TestRepository")
*/
class Test
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\OneToOne(targetEntity="MSSQL\Entity\Test")
* @ORM\JoinColumn(name="id_mssql", referencedColumnName="id_mssql")
*/
private $mssql;
我想就這兩個連接:(