Skip to content

Oracle:Known Issues

Derek Jones edited this page Jul 5, 2012 · 8 revisions

This page lists known issues with the Oracle Database Driver (and it's solution if possible).

Connection Parameters

Not all of the parameters in application/config/database.php are used as one might expect. Namely, $db['default']['database'] isn't used at all. The value used for $db['default']['hostname'] depends on whether the Oracle client's tnsnames.ora file exists and contains information about the database to be used. If the file exists and is configured for the intended database, this parameter should be set to the symbolic name. Otherwise, it should be set to a single string of the connection parameters that tnsmames.ora would normally contain.

An example of connection parameters for the latter case:

$db['default']['hostname'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost.example.com)(PORT=1521))(CONNECT_DATA=(SID=dbsid)))';
$db['default']['username'] = 'dbuser';
$db['default']['password'] = 'dbpassword';
$db['default']['database'] = ''; // not used by this Oracle driver
$db['default']['dbdriver'] = 'oci8';

In this case, the appropriate values need to be set for the HOST, PORT, and SID keywords in the hostname parameter.

Different queries return the same results

If you run two different queries in the same script you can run into the problem, that both queries return the same result.

Example

$this->load->database();
$query1 = $this->db->query("SELECT * FROM table1");
$result1 = $query1->result(); // Returns Value of table 1
$query1->free_result();

$query2 = $this->db->query("SELECT * FROM table2");
$result2 = $query2->result(); // Also returns Value of table 1

Solution

In file codeigniter/database/driver/oci8/oci8_driver.php you should change the lines

function _set_stmt_id($sql)
    {
        if ( ! is_resource($this->stmt_id))
        {
            $this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
        }
    }

to

function _set_stmt_id($sql)
    {
        $this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
    }

Category:Library::Database::Oracle | Category:Libraries::Database::Oracle | Category:Contributions::Libraries::Database::Oracle

Clone this wiki locally