0

Hello.

I received some code that has a section in which the variable $DB is established.

$DB =& new DB($db_username, $db_password, $db_dsn, false);

It does this by calling a function named DB, which is shown here below.

    /**
    * Constructor
    *
    * will set $DB->error and return false if login fails
    *
    * @param string $user
    * @param string $password
    * @param string $db_name
    * @param bool $persistent Should this be a persistent db connection ?
    * @param integer $int_mode
    * @return bool
    **/
    function DB ( $user, $password, $db_name, $persistent=TRUE, $int_mode=OCI_COMMIT_ON_SUCCESS )
    {
        $this->_valid_connection = false;
        $this->query_count = 0;
        $this->debug = false;
        $this->statement_handle = '';
        $this->int_mode = $int_mode;

        if ( $persistent )
        {
            $this->db_handle = OCIPlogon($user,$password,$db_name, 'AMERICAN_AMERICA.AL32UTF8');
        } else {
            $this->db_handle = OCIlogon($user,$password,$db_name, 'AMERICAN_AMERICA.AL32UTF8');
        }

        if ( !$this->db_handle )
        {
            $this->throwError(OCIerror());
            Message::addAlert('Error: Unable to connect to Database');
            return false;
        }
        return true;
    }

    /**
    * Destructor
    *
    * this will only get called if you call it ( limitation of the current version of PHP )
    * but don't worry... PHP cleans up after us anyway.
    *
    * @return void
    **/
    function _DB ()
    {
        OCILogOff($this->db_handle);
    }

But I'm having trouble understanding exactly what it does and when run all I get is a blank page. Can somebody please explain why the DB function is not working correctly?

Thanks.

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by veedeoo
0

Hi,

This class is a DB connector class.. you still have to provide the query for it to work..

I just want to let you know that OCIPlogon alias has been deprecated. Use oci_pconnect instead.

Edited by veedeoo: info added

This topic has been dead for over six months. 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.