Welcome Guest, Not a member yet? Register   Sign In
CI+oci8+stored procedure=Anonymous error.
#1

[eluser]Unknown[/eluser]
Hello. I'm trying to use oci8 driver for calling stored procedure, but getting database error message without number or description, just with SQL code.
I have changed code in oci8_driver.php twice:

1)changed:
Code:
function db_connect()

    {

        return @ocilogon($this->username, $this->password, $this->hostname);

    }
to:
Code:
function db_connect()

    {

        return @ocilogon($this->username, $this->password, $this->hostname, $this->char_set);

    }
for proper display of cyrillic symbols,

2)changed

Code:
function _bind_params($params)

    {

        if ( ! is_array($params) OR ! is_resource($this->stmt_id))

        {

            return;

        }

        

        foreach ($params as $param)

        {

             foreach (array('name', 'value', 'type', 'length') as $val)

            {

                if ( ! isset($param[$val]))

                {

                    $param[$val] = '';

                }

            }



            ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);

        }

    }
to
Code:
function _bind_params($params)

    {

        if ( ! is_array($params) OR ! is_resource($this->stmt_id))

        {

            return;

        }

        

        foreach ($params as $param)

        {

             foreach (array('name', 'value', 'type', 'length') as $val)

            {

                if ( ! isset($param[$val]))

                {

                    $param[$val] = FALSE;

                }

            }



            ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);

        }

    }

Because of getting warnings about type mismatch.

controllers code:
Code:
<?php

class Test extends Controller{

    function index(){

        $user=array('login'=>'someuser',
                    'password'=>'somepass',
        );        

        $transaction=array('result'=>'-1');

        $params=array(

            array('name'=>':p_login' , 'value'=>$user['login'] , 'length'=>'255'),
            array('name'=>':p_passwd' , 'value'=>$user['password'] , 'length'=>'255'),
            array('name'=>':p_result', 'value'=>$transaction['result'], 'length'=>'255')

        );

        $this->db->stored_procedure('test_package', 'test_procedure', $params);


        echo $transaction['result'];
    }

}

?>
Exactly same SQL code worked fine in clear PHP.
How to handle error?
#2

[eluser]Cego[/eluser]
I've tried to get around the warnings handled. I'm trying to use the same kinda structure as you, going for store procedures also.

I've done somethings, but crashing apache in the process.

in oci8_drive.php
Code:
function _bind_params($params) {
        if ( ! is_array($params) OR ! is_resource($this->stmt_id)) {
            return;
        }

        foreach ($params as $param) {
            foreach (array('name', 'value', 'type', 'length') as $val) {
                if ( ! isset($param[$val])) {
                    $param[$val] = '';
                }
            }

            ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length']);
        }
    }
I've removed the $param['type'], from the function ocibindbyname cuz it always warning for the fact it wanted a long value and received a string, because of this line: $param[$val] = '';

now I'm trying to call the store procedure like this:
Code:
$transaction=array('result'=>'-1');
        $paramsFST = array(
'name' => ':cod', 'value' => $id,'length' => 255
);
        $result = array(
'name' => ':my_record', 'value' => $transaction['result'],'length' => 255
);
        $paramsArray = array($paramsFST,$result);

        $this->db->stored_procedure("PROCEDURESPACK", "RETURNLIVRO",$paramsArray);
        echo $result['value'];

Any thoughts?
#3

[eluser]Unknown[/eluser]
I managed to find my old rewriten driver, here it is http://www.mediafire.com/?kxwyzzzkgod
#4

[eluser]Cego[/eluser]
Thx a million, I'll try and get back at you Wink




Theme © iAndrew 2016 - Forum software by © MyBB