【发布时间】:2015-02-21 10:20:17
【问题描述】:
所以我在数据库中有一个学校项目。我们需要为我的项目连接到 MySQL 的公司创建一个数据库,但后来我的老师说我们需要使用 Oracle。所以我试图寻找答案,但我失败了。我试图在这里找到旧主题,但它不起作用。首先,我尝试通过将分号 (;) 删除到 php.ini extension=php_oci8_11g.dll 中来连接 Oracle 中的 xampp,但出现错误。
“PHP 启动:无法加载动态库 'C:\xampp\php\ext\php_oci8.dll' - %1 不是有效的 Win32 应用程序” 我在 windows 8.1 64bit 中运行它
我还没有尝试添加环境路径,因为我不知道在哪里。
这是我的数据库.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 */
希望你们能帮助我。谢谢!
【问题讨论】:
-
我认为您正在尝试使用 XAMPP 的 32 位 Apache/PHP 组合运行 64 位 oracle dll。卸载您的 Oracle 客户端并获取 32 位版本。
标签: php mysql database oracle codeigniter