本文介绍了Codeigniter Oracle PDO-oci的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Codeigniter中开发一个应用程序.我有Oracle数据库和大量要在我的应用程序中使用的数据.我想连接PDO-oci.

I am developing an application in Codeigniter. i have Oracle database and large number of data to use in my application.i want to connect PDO-oci.

我没有找到任何解决方案. 请帮助我将 oracle PDO-OCI连接到codeigniter.

i didn't find any solution. Please help me to connect oracle PDO-OCI to codeigniter.

$db['default'] = array(
    'dsn'   => 'mysql:dbname=(DESCRIPTION =
                    (ADDRESS = (PROTOCOL = TCP)(HOST = MY HOST NAME)(PORT = 1521))
                    (CONNECT_DATA =
                      (SERVER = DEDICATED)
                      (SERVICE_NAME = orcl)
                    )
                  )',
    'hostname' => '',
    'username' => 'MYUSERNAME',
    'password' => 'MYPASSWORD',
    'database' => '',
    'dbdriver' => 'oci8',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE

,错误是

屏幕截图

推荐答案

您的DSN无效.如PHP手册中记录所示,DSN前缀应为像这样:

Your DSN is invalid. As documented in the PHP manual the DSN prefix should be oci: like so:

'dsn'   => 'oci:dbname=(DESCRIPTION =
                (ADDRESS = (PROTOCOL = TCP)(HOST = MY HOST NAME)(PORT = 1521))
                (CONNECT_DATA =
                  (SERVER = DEDICATED)
                  (SERVICE_NAME = orcl)
                )
              )',

但是,我建议您使用'EZCONNECT'语法,因为这不会使您的代码混乱:

I would, however, recommend using the 'EZCONNECT' syntax as this doesn't clutter your code:

'dsn' => 'oci:dbname=hostname/orcl',

这篇关于Codeigniter Oracle PDO-oci的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 18:52