Location: PHPKode > scripts > Piragibe > piragibe/PGBConnection/PGBDbxConnection/PGBDbxOracleConnection.php
<?php
require_once 'Piragibe/PGBConnection/PGBDbxConnection.php';
/**
 * A connection to an ORACLE database via DBX.
 * @package Piragibe
 * @author Francisco Piragibe
 * @version 1.00
 * @subpackage PGBConnection/PGBDbxConnection
 * @copyright Copyright &copy; 2006, Francisco Piragibe
 * This file is part of The PIRAGIBE Framework.
 *
 * The PIRAGIBE Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * The PIRAGIBE Framework is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with The PIRAGIBE Framework; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
class PGBDbxOracleConnection extends PGBDbxConnection {

    /**
     * Standard constructor.
     * @param string $pUser ORACLE username
     * @param string $pPw ORACLE password
     * @param string $pHost hostname of ORACLE server (or IP address)
     * @param string $pDb SID or service name for ORACLE connection
     */
    function PGBDbxOracleConnection( $pUser, $pPw, $pHost, $pDb = '' ) {
        $w_db = '';
        if ( $pDb ) {
            $w_db = $pDb;
        }
        else {
            $w_db = $pHost;
        }
        parent::PGBDbxConnection( DBX_OCI8, $pHost, $w_db, $pUser, $pPw );
    }

    /**
     * Override for superclass method.
     * 
     * ORACLE databases are always in transaction-safe mode (i.e. always in a transaction).
     */
    function beginTrans() {
    }
    
    /**
     * Get a new sequence value for setting a PK.
     * 
     * As the base is always a sequence, it only works for numeric PK fields.
     * @return integer a numeric value guaranteed to be unique
     * @param string $pParm ORACLE sequence name
     */
    function getNewPkValue( $pParm ) {
        $rs = $this->query( 'SELECT ' . $pParm . '.nextval pk FROM DUAL' );
        $r  = $rs->getCurrentRecord();
        //print '<pre>PKG: ' . $r->getFieldValue( 'PK' ) . '</pre>';
        return $r->getFieldValue( 'PK' );
    }

}

?>
Return current item: Piragibe