PHP Oracle Connection DG?

时间:2017-08-14 06:47:27

标签: php oracle performance tcp

我想知道您是否可以提供示例代码以使PHP连接到oracle数据保护连接:

如下:

(DESCRIPTION =(ADDRESS_LIST =(FAILOVER = ON)(LOAD_BALANCE = OFF)(ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.XXX.XXX)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.XXX.XXY)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = XDG)))

我现在使用的是一个,但为了实现高可用性

到目前为止,

代码正在处理一个连接字符串:

$db['default'] = array(
    'dsn'   => '//XXX.XXX.XXX.XXX/C1',
    'hostname' => $sq_hostname,
    'username' => $sq_dbusername,
    'password' => $sq_dbpassword,
    'database' => $sq_dbname,
    'dbdriver' => 'oci8',
    'dbprefix' => '',
    'pconnect' => TRUE,
    'db_debug' => TRUE,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE,
    'autoinit' => TRUE
);

$db['serverdb'] = array(
    'dsn'   => '//XXX.XXX.XXX.XXX/C1',
    'hostname' => $sq_hostname,
    'username' => $sq_dbusername,
    'password' => $sq_dbpassword,
    'database' => $sq_dbname,
    'dbdriver' => 'oci8',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => TRUE,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

添加变量:

$tnsname ='(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.XXX.XXX)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = C1)))';

$sq_hostname=$tnsname;
$sq_dbname='C1';
$sq_dbusername='user';
$sq_dbpassword='password';

0 个答案:

没有答案