Public Member Functions

pgsqlSequence Class Reference

Public Member Functions

 __construct ($sequence, $max, $connection)
 Constructor.
 getSequence ()
 Return property for named sequence.
 setSequence ()
 Create sequence object.

Detailed Description

Definition at line 15 of file pgsqlSequence.php.


Constructor & Destructor Documentation

__construct ( sequence,
max,
connection 
)

Constructor.

public

Parameters:
str $sequence
int $max
mixed $connection

Definition at line 57 of file pgsqlSequence.php.

    {
        $this->objConnection = $connection;
        $this->objMax        = $max;
        $this->objSequence   = $sequence;
    }


Member Function Documentation

getSequence (  ) 

Return property for named sequence.

public

Returns:
mixed

Definition at line 70 of file pgsqlSequence.php.

    {
         return "NEXTVAL('" . $this->objSequence . "')";
    }

setSequence (  ) 

Create sequence object.

public

Returns:
mixed

Definition at line 81 of file pgsqlSequence.php.

    {
        //make sure $this->objMax is an unsigned int > 0
        $objMax = ( is_numeric( $this->objMax ) && $this->objMax > 0 ) ? ' MAXVALUE ' . ( int )$this->objMax : '';
        $objSeq = 'CREATE SEQUENCE ' . $this->objSequence . ' INCREMENT 1 MINVALUE 1' . $objMax . ' START 1';

        return pg_query( $this->objConnection, $objSeq )
        or trigger_error( pg_last_error( $this->objConnection ), E_USER_WARNING );
    }


The documentation for this class was generated from the following file: