Location: PHPKode > scripts > Piragibe > piragibe/PGBConnection/PGBDbxConnection/PGBDbxPostgresConnection.php
<?php
require_once 'Piragibe/PGBConnection/PGBDbxConnection.php';
/**
 * A connection to a POSTGRES database.
 * @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 PGBDbxPostgresConnection extends PGBDbxConnection {

    /**
     * Standard constructor.
     * @param string $pUser POSTGRES username
     * @param string $pPw POSTGRES password
     * @param string $pHost hostname of POSTGRES server (or IP address)
     * @param string $pDb database name to connect to
     */
    function PGBDbxPostgresConnection( $pUser, $pPw, $pHost, $pDb ) {
        parent::PGBDbxConnection( DBX_PGSQL, $pHost, $pDb, $pUser, $pPw );
    }

    /**
     * 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 POSTGRES sequence name
     */
    function getNewPkValue( $pParm ) {
        $rs = $this->query( 'SELECT nextval(\'' . $pParm . '\') as pk' );
        $r  = $rs->getCurrentRecord();
        return $r->getFieldValue( 'pk' );
    }
    
    /**
     * POSTGRES specific implementation for the PK generator
     * 
     * @return integer a PK value
     */
    function getNewId() {
        return $this->getNewPkValue( 'public.sq_pk' );
    }

}

?>
Return current item: Piragibe