CodeIgniter Forums
Oracle OCI8 support for CI 4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forum-29.html)
+--- Thread: Oracle OCI8 support for CI 4 (/thread-76381.html)

Pages: 1 2


Oracle OCI8 support for CI 4 - ajk - 05-07-2020

Is there a time frame for when Oracle OCI8 will be supported with CI 4 ?


RE: Oracle OCI8 support for CI 4 - kilishan - 05-07-2020

There is a pull request waiting for review and integration. If you wanted to speed the process along, you could pull down that branch and run it through the tests and see how close it gets. I don't have Oracle installed currently so this would go a huge way toward getting it integrated.


RE: Oracle OCI8 support for CI 4 - ajk - 04-15-2021

I have taken the code from the pull request and testing it with Oracle 12c.


RE: Oracle OCI8 support for CI 4 - kenjis - 10-13-2021

It's been quite a while, but we are getting close to getting the Oracle driver into CI4.

If anyone can test it, please pull down the branch of the PR https://github.com/codeigniter4/CodeIgniter4/pull/2487 and test it.


RE: Oracle OCI8 support for CI 4 - gurthang75 - 10-25-2021

Hi! im testing the oralce driver and i got some bugs in it.. ill listing over here:
1) storeProcedures are not working correctly im doing something like this:
PHP Code:
$query $db->storedProcedure('PAC_WIKI''INSERT_DOCUMENT'$params);
return 
$query

and get the next error:
oci_parse() expects parameter 1 to be resource, bool given
SYSTEMPATH\Database\OCI8\Connection.php at line 507
Code:
500             if (isset($param['type']) && $param['type'] === OCI_B_CURSOR) {
501                 $haveCursor = true;
502             }
503         }
504         $sql = trim($sql, ',') . '); END;';
505         
506         $this->resetStmtId = false;
507         $this->stmtId      = oci_parse($this->connID, $sql);


its seems like $this->connID is not retrivieng the connection
2) this storeProcedure will work with procedures in packages but it will not work (i think) with procedures alone without a package
Code:
public function storedProcedure(string $package, string $procedure, array $params)
    {
        if ($package === '' || $procedure === '') {
            throw new DatabaseException(lang('Database.invalidArgument', [$package . $procedure]));
        }

        // Build the query string
        $sql = 'BEGIN ' . $package . '.' . $procedure . '(';

Last but not least.... i dont know if this is the correct place to show bugs or anything...



RE: Oracle OCI8 support for CI 4 - gurthang75 - 10-26-2021

Hi Boyos!
i fixed the problem rewriting the Connection.php from the OCI8 Driver this way:
Code:
public function storedProcedure(string $package, string $procedure, array $params)
    {
        if ($package === '' || $procedure === '') {
            throw new DatabaseException(lang('Database.invalidArgument', [$package . $procedure]));
        }

        // Build the query string
        $sql = 'BEGIN ' . $package . '.' . $procedure . '(';

        $haveCursor = false;

        foreach ($params as $param) {
            $sql .= $param['name'] . ',';

            if (isset($param['type']) && $param['type'] === OCI_B_CURSOR) {
                $haveCursor = true;
            }
        }
        $sql = trim($sql, ',') . '); END;';

        /** by gus */
        try {
            // Connect to the database and set the connection ID
            $this->connID = $this->connect($this->pConnect);
        } catch (Throwable $e) {
            $connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage());
            log_message('error', 'Error connecting to the database: ' . $e->getMessage());
        }
        /** by gus */

        $this->resetStmtId = false;
        $this->stmtId      = oci_parse($this->connID, $sql);
        $this->bindParams($params);
        /** by gus CHANGE FOR NULL */
        $result            = $this->query($sql, null, $haveCursor);
        $this->resetStmtId = true;

        /** by gus */
        $this->close();
        /** by gus */
        return $result;
    }

    /**
    * Bind parameters
    *
    * @param array $params
    *
    * @return void
    */
    protected function bindParams($params)
    {
        if (! is_array($params) || ! is_resource($this->stmtId)) {
            return;
        }

        foreach ($params as $param) {
            foreach (['name', 'value', 'type', 'length'] as $val) {
                if (! isset($param[$val])) {
                    /** by gus */
                    $param[$val] = null;
                    /** by gus */
                }
            }
            /** by gus */
            $param['length'] = ($param['length'] == null)? -1 : $param['length'];
            $param['type'] = ($param['type'] == null)? SQLT_CHR : $param['type'];
            /** by gus */
            oci_bind_by_name($this->stmtId, $param['name'], $param['value'], $param['length'], $param['type']);
        }
    }


All yours for testing!
Salute!


RE: Oracle OCI8 support for CI 4 - b126 - 10-30-2021

(10-13-2021, 12:11 AM)kenjis Wrote: It's been quite a while, but we are getting close to getting the Oracle driver into CI4.

If anyone can test it, please pull down the branch of the PR https://github.com/codeigniter4/CodeIgniter4/pull/2487 and test it.

Hi Kenji,

I have downloaded it and I am testing it against an Oracle Database 12c Release 2 Enterprise Edition (12.2.0.1.0).
It seems to work pretty well with the Doctrine integration (CLI ORM mapping, auto generation of entities, etc.)

Regards,
Bert


RE: Oracle OCI8 support for CI 4 - kenjis - 10-30-2021

(10-25-2021, 01:08 PM)gurthang75 Wrote: Last but not least.... i dont know if this is the correct place to show bugs or anything...[/code]

Don't worry. I saw your report. Thanks!

But if you report a bug on GitHub, you don't have to worry about us missing it.

(10-30-2021, 01:28 PM)b126 Wrote: I have downloaded it and I am testing it against an Oracle Database 12c Release 2 Enterprise Edition (12.2.0.1.0).
It seems to work pretty well with the Doctrine integration (CLI ORM mapping, auto generation of entities, etc.)

Thank you for your cooperation!


RE: Oracle OCI8 support for CI 4 - gurthang75 - 11-23-2021

HI again!
im having troubles with package/procedures executions when i got OUT variables in my package i dont know how to retrieve the returning OUT variable value.
Can someone gide me a bit? im foing this:
Code:
function addSection($parent_section, $sec_code, $sec_long){
        $params[0] = array('name' => ':P_PARENT_SEC', 'value' => $parent_section);
        $params[1] = array('name' => ':P_CODE', 'value' => $sec_code);
        $params[2] = array('name' => ':P_LONG', 'value' => $sec_long);
        $params[3] = array('name' => ':P_OPER', 'value' => 'add');
        $params[4] = array('name' => ':P_RESULT', 'value' => null, 'length' => 4000);
        $params[5] = array('name' => ':P_ERROR', 'value' => null, 'length' => 4000);
        $params[6] = array('name' => ':P_ERROR_ORA', 'value' => null, 'length' => 4000);

        $query = $this->db->storedProcedure('PAC_WIKI', 'WIKI_SECTION', $params);
        print_r($query);

        die();
        if ($this->db->transStatus() === false) {
            return $query;
        } else {
            return $query;
        }
    }

and that "print_r()" give me this array:
Code:
CodeIgniter\Database\OCI8\Result Object ( [connID] => Resource id #12 [resultID] => Resource id #13 [resultArray] => Array ( ) [resultObject] => Array ( ) [customResultObject] => Array ( ) [currentRow] => 0 [numRows:protected] => [rowData] => )


thks in advance!


RE: Oracle OCI8 support for CI 4 - kenjis - 11-28-2021

See Example #6 Using a PL/SQL stored procedure in https://www.php.net/manual/en/oci8.examples.php