zend framework 1 连接oracle数据库的写法

时间:2022-04-27 16:42:32

1 用Zend_Db_Adapter_Pdo_Oci方式

$config =array(
'host'=>'192.168.5.40',
'port'=>'1521',
'dbname'=> 'orclxxxx',
'charset'=>'UTF8',
'username' => 'xxxx',
'password' => 'xxxx',
);
$db = Zend_Db::factory("PDO_OCI", $config);

2 用Zend_Db_Adapter_Oracle方式
$oracle_config= array(
'dbname' => '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.40)(PORT = 1521)))(CONNECT_DATA =(SID=orclxxxx)))',
'username' => 'xxxx',
'password' => 'xxxxx',
'charset'=>'UTF8',
);
$db = Zend_Db::factory("oracle", $oracle_config);

$db->setFetchMode(Zend_Db::FETCH_ASSOC);
Zend_Db_Table::setDefaultAdapter($db);