irm-1.6-b3/MDB/oci8.php
/**
     * Connect to the database
     * 
     * @return TRUE on success, MDB_Error on failure
     */
Connect to the database

@return TRUE on success, MDB_Error on failure
Connect to the database @return TRUE on success MDB_Error on failure
function connect($user = NULL , $password = NULL, $persistent = NULL)
    {
        if($user === NULL) {
            $user = $this->user;
        }
        if($password === NULL) {
            $password = $this->password;
        }
        if($persistent === NULL) {
            $persistent = $this->getOption('persistent');
        }
        if (isset($this->host)) {
            $sid = $this->host;
        } else {
            $sid = getenv('ORACLE_SID');
        }
        if(!strcmp($sid, '')) {
            return($this->raiseError(MDB_ERROR, NULL, NULL,
                'Connect: it was not specified a valid Oracle Service IDentifier (SID)'));
        }
        if($this->connection != 0) {
            if (!strcmp($this->connected_user, $user)
                && !strcmp($this->connected_password, $password)
                && $this->opened_persistent == $persistent)
            {
                return(MDB_OK);
            }
            $this->_close();
        }
        if(!PEAR::loadExtension($this->phptype)) {
            return(PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND,
                NULL, NULL, 'extension '.$this->phptype.' is not compiled into PHP',
                'MDB_Error', TRUE));
        }
        if (isset($this->options['HOME'])) {
            putenv('ORACLE_HOME='.$this->options['HOME']);
        }
        putenv('ORACLE_SID='.$sid);
        $function = ($persistent ? 'OCIPLogon' : 'OCINLogon');
        if (!function_exists($function)) {
            return($this->raiseError(MDB_ERROR, NULL, NULL,
                'Connect: Oracle OCI API support is not available in this PHP configuration'));
        }
        if (!($this->connection = @$function($user, $password, $sid))) {
            return($this->oci8RaiseError(NULL,
                'Connect: Could not connect to Oracle server'));
        }
        if (MDB::isError($doquery = $this->_doQuery("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"))) {
            $this->_close();
            return($doquery);
        }
        if (MDB::isError($doquery = $this->_doQuery("ALTER SESSION SET NLS_NUMERIC_CHARACTERS='. '"))) {
            $this->_close();
            return($doquery);
        }
        $this->connected_user = $user;
        $this->connected_password = $password;
        $this->opened_persistent = $persistent;
        return(MDB_OK);
    }
function connect ( $ user = NULL , $ password = NULL , $ persistent = NULL ) { if ( $ user === NULL ) { $ user = $ this -> user ; } if ( $ password === NULL ) { $ password = $ this -> password ; } if ( $ persistent === NULL ) { $ persistent = $ this -> getOption ( 'persistent' ) ; } if ( isset ( $ this -> host ) ) { $ sid = $ this -> host ; } else { $ sid = getenv ( 'ORACLE_SID' ) ; } if ( ! strcmp ( $ sid , '' ) ) { return ( $ this -> raiseError ( MDB_ERROR , NULL , NULL , 'Connect: it was not specified a valid Oracle Service IDentifier (SID)' ) ) ; } if ( $ this -> connection != 0 ) { if ( ! strcmp ( $ this -> connected_user , $ user ) && ! strcmp ( $ this -> connected_password , $ password ) && $ this -> opened_persistent == $ persistent ) { return ( MDB_OK ) ; } $ this -> _close ( ) ; } if ( ! PEAR :: loadExtension ( $ this -> phptype ) ) { return ( PEAR :: raiseError ( NULL , MDB_ERROR_NOT_FOUND , NULL , NULL , 'extension ' . $ this -> phptype . ' is not compiled into PHP' , 'MDB_Error' , TRUE ) ) ; } if ( isset ( $ this -> options [ 'HOME' ] ) ) { putenv ( 'ORACLE_HOME=' . $ this -> options [ 'HOME' ] ) ; } putenv ( 'ORACLE_SID=' . $ sid ) ; $ function = ( $ persistent ? 'OCIPLogon' : 'OCINLogon' ) ; if ( ! function_exists ( $ function ) ) { return ( $ this -> raiseError ( MDB_ERROR , NULL , NULL , 'Connect: Oracle OCI API support is not available in this PHP configuration' ) ) ; } if ( ! ( $ this -> connection = @ $ function ( $ user , $ password , $ sid ) ) ) { return ( $ this -> oci8RaiseError ( NULL , 'Connect: Could not connect to Oracle server' ) ) ; } if ( MDB :: isError ( $ doquery = $ this -> _doQuery ( " ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS' " ) ) ) { $ this -> _close ( ) ; return ( $ doquery ) ; } if ( MDB :: isError ( $ doquery = $ this -> _doQuery ( " ALTER SESSION SET NLS_NUMERIC_CHARACTERS='. ' " ) ) ) { $ this -> _close ( ) ; return ( $ doquery ) ; } $ this -> connected_user = $ user ; $ this -> connected_password = $ password ; $ this -> opened_persistent = $ persistent ; return ( MDB_OK ) ; }
Connect to the database
Connect to the database