0

Hi all;
I just edited the oci8_driver in codeigniter and added the oci_bind_array_by_name since it was not included. But my codes does not work.. Hope somebody out there can help me.

oci8_driver function for store procedure

private function _bind_params($params)
    {
        if ( ! is_array($params) OR ! is_resource($this->stmt_id))
        {
            return;
        }

        foreach ($params as $param)
        {
            if (!isset($param['name'])) continue;
            if (!isset($param['value']))
                $param['value']='';

            if (is_array($param['value'])): // i added this one
                if (!isset($param['length'])) {
                    $length=count($param['value']);
                    oci_bind_array_by_name($this->stmt_id, $param['name'], $param['value'],$length);
                }
                elseif (!isset($param['type']))
                    oci_bind_array_by_name($this->stmt_id, $param['name'], $param['value']
                    , $param['length']);
                else
                    oci_bind_array_by_name($this->stmt_id, $param['name']
                    , $param['value'], $param['length'], $param['type']);
            else:

                if (!isset($param['length']))
                oci_bind_by_name($this->stmt_id, $param['name'], $param['value']);
                elseif (!isset($param['type']))
                    oci_bind_by_name($this->stmt_id, $param['name'], $param['value']
                    , $param['length']);
                else
                    oci_bind_by_name($this->stmt_id, $param['name']
                    , $param['value'], $param['length'], $param['type']);
            endif;
        }
    }

// My function in model for saving and calling the procedure in oracle

public function getDocSubmitted($data1=false,$data2=false,$data3=false, $appNo=false, $empcode=false){
        if ($appNo===false) return false;
        if (!is_array($data = $data1)){
            return false;
        }
        else {
        $param=array(
             array('name'=>':ControlNo','value'=>$appNo)
            ,array('name'=>':Data1Array','value'=>$data1)
            ,array('name'=>':Data2Array','value'=>$data2)
            ,array('name'=>':Data3Array','value'=>$data3)
            ,array('name'=>':EmpCode','value'=>$empcode)
            ,array('name'=>':Code','value'=>&$cd, 'length'=>100)
            ,array('name'=>':Msg','value'=>&$Msg, 'length'=>100)
            );
        $this->dbconn->stored_procedure('FAP.PKG_WEBFAP','Proc_FAPSubmitDocuments',$param);
        $result['Msg'] = $Msg;
        $result['Code'] = $cd;
        oci_free_statement($this->dbconn->stmt_id);
        return $Msg;
        }
    }

No error in the run time.. Thanks

1
Contributor
1
Reply
6
Views
3 Years
Discussion Span
Last Post by kit007
1

made some mistakes on my oci_bind_array_by_name..
this my solution

foreach ($params as $param)
        {
            if (!isset($param['name'])) continue;
            if (!isset($param['value']))
                $param['value']='';

            if (is_array($param['value'])):
                if (!isset($param['length'])) {
                    $length=count($param['value']);
                    // from this oci_bind_array_by_name($this->stmt_id, $param['name'], $param['value'],$length);
                    oci_bind_array_by_name($this->stmt_id, $param['name'], $param['value'],$length,-1,SQLT_CHR);
                }
                elseif (!isset($param['type']))
                    oci_bind_array_by_name($this->stmt_id, $param['name'], $param['value']
                    , $param['length'],-1,SQLT_CHR);
                else
                    oci_bind_array_by_name($this->stmt_id, $param['name']
                    , $param['value'], $param['length'], $param['type']);
            else:

                if (!isset($param['length']))
                oci_bind_by_name($this->stmt_id, $param['name'], $param['value']);
                elseif (!isset($param['type']))
                    oci_bind_by_name($this->stmt_id, $param['name'], $param['value']
                    , $param['length']);
                else
                    oci_bind_by_name($this->stmt_id, $param['name']
                    , $param['value'], $param['length'], $param['type']);
            endif;
        }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.