如何将oracle中的CodeIgniter与XAMPP连接


How do I connect CodeIgniter in oracle with XAMPP

所以我在数据库中有一个学校项目。我们需要为一家公司创建一个数据库,我的项目连接到MySQL,但后来我的老师说我们需要使用Oracle。所以我试图寻找答案,但我失败了。我试着在这里找一些老话题,但没有用。首先,我试图通过在php.ini扩展名=php_oci8_11g.dll中删除分号(;)来连接oracle中的examplep,但我遇到了一个错误。

"PHP启动:无法加载动态库"C:''examplep''PHP''ext''PHP_oci8.dll"-%1不是有效的Win32应用程序"我在windows 8.1 64位中运行它

我仍然没有尝试添加环境路径,因为我不知道在哪里。

这是我的数据库.php

    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    /*
    | -------------------------------------------------------------------
    | DATABASE CONNECTIVITY SETTINGS
    | -------------------------------------------------------------------
    | This file will contain the settings needed to access your database.
    |
    | For complete instructions please consult the 'Database Connection'
    | page of the User Guide.
    |
    | -------------------------------------------------------------------
    | EXPLANATION OF VARIABLES
    | -------------------------------------------------------------------
    |
    |   ['hostname'] The hostname of your database server.
    |   ['username'] The username used to connect to the database
    |   ['password'] The password used to connect to the database
    |   ['database'] The name of the database you want to connect to
    |   ['dbdriver'] The database type. ie: mysql.  Currently supported:
                 mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
    |   ['dbprefix'] You can add an optional prefix, which will be added
    |                to the table name when using the  Active Record class
    |   ['pconnect'] TRUE/FALSE - Whether to use a persistent connection    
    |   ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
    |   ['cache_on'] TRUE/FALSE - Enables/disables query caching
    |   ['cachedir'] The path to the folder where cache files should be stored
    |   ['char_set'] The character set used in communicating with the database
    |   ['dbcollat'] The character collation used in communicating with the database
    |                NOTE: For MySQL and MySQLi databases, this setting is only used
    |                as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
    |                (and in table creation queries made with DB Forge).
    |                There is an incompatibility in PHP with mysql_real_escape_string() which
    |                can make your site vulnerable to SQL injection if you are using a
    |                multi-byte character set and are running versions lower than these.
    |                Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
    |   ['swap_pre'] A default table prefix that should be swapped with the dbprefix
    |   ['autoinit'] Whether or not to automatically initialize the database.
    |   ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
    |                           - good for ensuring strict SQL while developing
    |
    | The $active_group variable lets you choose which connection group to
    | make active.  By default there is only one group (the 'default' group).
    |
    | The $active_record variables lets you determine whether or not to load
    | the active record class
    */
    $active_group = 'default';
    $active_record = TRUE;

    $tnsname = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
        (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))';
    $db['default']['hostname'] = '$tnsname';
    $db['default']['username'] = 'xxxxxxx'; //what's this? the username of what?
    $db['default']['password'] = 'xxxxxxx'; // this the password for oracle?
    $db['default']['database'] = 'hr';
    $db['default']['dbdriver'] = 'oci8';
    $db['default']['dbprefix'] = '';
    $db['default']['pconnect'] = TRUE;
    $db['default']['db_debug'] = TRUE;
    $db['default']['cache_on'] = FALSE;
    $db['default']['cachedir'] = '';
    $db['default']['char_set'] = 'utf8';
    $db['default']['dbcollat'] = 'utf8_general_ci';
    $db['default']['swap_pre'] = '';
    $db['default']['autoinit'] = TRUE;
    $db['default']['stricton'] = FALSE;

    /* End of file database.php */
    /* Location: ./application/config/database.php */

希望你们能帮助我。谢谢!

您必须下载Database Instant Client,然后选择Basic或Litle Edition和sdk,在windows中您需要添加系统环境path的路径。然后在php.ini中取消对的行的注释;extension=php_oci8.dll,然后重新启动您的apache。

你好!