hi all,

I am new to Codeigniter, start learning because of one of our customer want the conversion of their some Oracle Forms to web app and I found it is much easier to use CI framework of PHP but one thing I can't connect / work with their Oracle database 12c Release 2. I have a VM with Win 8, Oracle DB 12c and WAMP ( latest downloaded on 10-Nov-2018 ). I searched for it and found various solution (not any of 12c), tried some but still I failed to even load data from a table.
can somebody help me, I can upload my project files if here is option and I can.
I have modified php.ini file in Apache to un-remark for line extension=oci8_12c and have entry in database.php ( 2 entries are there first for Mysql and another one for Oracle )

$active_group = 'default';  // MYSQL entry
$query_builder = TRUE;

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'mydb01',
    'dbdriver' => 'mysqli',
    '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
);

$active_group = 'oracle';  // Oracle entry
$query_builder = TRUE;

$db['oracle'] = array(
    'dsn'   => '',
    'hostname' => 'localhost/orclpdb',
    'username' => 'hr',
    'password' => 'hr',
    'database' => 'orclpdb',
    '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
);

more entries i tried, will show here if someone want ( or can upload files )

Please help in this matter.
regards

following entries i have tested in database.php file ( please note: I have posted here Partial entries to avoid very long code )

Message: oci_connect(): ORA-01017: invalid username/password; logon denied

    $db['default'] = array(
    'dsn'   => 'oci:dbname=(DESCRIPTION =
                (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
                (CONNECT_DATA =
                  (SERVER = DEDICATED)
                  (SERVICE_NAME = orclpdb)
                )
              )',
    'port'  => 1521,
    'hostname' => '',
    'username' => 'hr',
    'password' => 'hr',
    'database' => '',
    'dbdriver' => 'oci8',
    'dbprefix' => '',
    'pconnect' => FALSE,
);

and

$db['default'] = array(
    'dsn'   => 'oci:dbname=localhost/orclpdb',
    'port'  => 1521,
    'hostname' => '',
    'username' => 'hr',
    'password' => 'hr',
    'database' => '',
    'dbdriver' => 'oci8',
    'dbprefix' => '',
    'pconnect' => FALSE,

Message: oci_execute(): ORA-00942: table or view does not exist

    $db['default'] = array(
    'dsn'   => '',
    'port'  => 1521,
    'hostname' => 'localhost',
    'username' => 'hr',
    'password' => 'hr',
    'database' => 'orclpdb',
    'dbdriver' => 'oci8',
    'dbprefix' => '',
    'pconnect' => FALSE,

and

$db['default'] = array(
    'dsn'   => 'oci:dbname=localhost/orclpdb',
    'port'  => 1521,
    'hostname' => 'localhost',
    'username' => 'hr',
    'password' => 'hr',
    'database' => 'orclpdb',
    'dbdriver' => 'oci8',
    'dbprefix' => '',
    'pconnect' => FALSE,

and

$dbhost = "127.0.0.1"; //host 
$dbport= "1521"; //port default is 1521 
$dbname = "orclpdb"; //name of database 
$dbuser = "hr"; //db user with all priviliges
$dbpassword = "hr"; // password of user
$dbConnString = "(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = ". $dbhost .")(PORT = ". $dbport ."))
)(CONNECT_DATA =(SERVICE_NAME = ". $dbname .")))"; // connection string for this we must create TNS entry for Oracle 

$db['default']['hostname'] = $dbConnString;
$db['default']['username'] = $dbuser;
$db['default']['password'] = $dbpassword;
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

Wish I could help. I have a lot of PHP and CI experience, but no Oracle experience. What does the error log say? It should be writing to a log in /application/logs by default.

thanks for reply, the log file says Directory access is forbidden and nothing else, just this one single line.
but same files using for mysql without any problem.

following Error messages received when running it:

-->>
A PHP Error was encountered

Severity: Warning

Message: oci_execute(): ORA-00942: table or view does not exist

Filename: oci8/oci8_driver.php

Line Number: 286

Backtrace:

File: C:\wamp64\www\myproject\application\models\Dept_model.php
Line: 15
Function: get

File: C:\wamp64\www\myproject\application\controllers\Depts.php
Line: 8
Function: getDept

File: C:\wamp64\www\myproject\index.php
Line: 315
Function: require_once
.

A Database Error Occurred

Error Number: 942

ORA-00942: table or view does not exist

SELECT * FROM "departments"

Filename: C:/wamp64/www/myproject/system/database/DB_driver.php

Line Number: 691
<<--

hope that can help to find out solution :)

regards

Try :
SELECT * FROM departments
without the quotes

OR maybe, prefix your table name even if not needed
SELECT * FROM hr.departments

I'm using codeigniter with oracle12c like you and it works.
I compared your config with mine and everything looks fine.
Indeed, you got an oracle error message... so you have a connection to db

hi, thanks very much for your reply and advice. sorry for delay in reply.
for which config ? as i have posted various i tried out. please inform so i use that particular one :)
i didn't write any sql statement, what you see here is by built in Query Builder.
in model i used: $this->oracle_db=$this->load->database('default',true); ( for very first post i am using ('oracle',true); )
regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.