Public Member Functions | |
__construct ($sequence, $max, $connection) | |
Constructor. | |
getSequence () | |
Return int value for named sequence. | |
setSequence () | |
Create sequence. |
Definition at line 15 of file db2Sequence.php.
__construct | ( | $ | sequence, | |
$ | max, | |||
$ | connection | |||
) |
Constructor.
public
str | $sequence | |
int | $max | |
mixed | $connection |
Definition at line 57 of file db2Sequence.php.
{ $this->objConnection = $connection; $this->objMax = $max; $this->objSequence = $sequence; }
getSequence | ( | ) |
Return int value for named sequence.
public
Definition at line 70 of file db2Sequence.php.
{ $objStmt = db2_exec( $this->objConnection, 'SELECT NEXTVAL FOR ' . $this->objSequence . ' FROM SYSIBM.SYSDUMMY1' ) or trigger_error( db2_stmt_errormsg(), E_USER_WARNING ); $objResult = db2_fetch_array( $objStmt ); return $objResult[0]; }
setSequence | ( | ) |
Create sequence.
public
Definition at line 85 of file db2Sequence.php.
{ //make sure $this->objMax is an unsigned int > 0 $objMax = ( is_numeric( $this->objMax ) && $this->objMax > 0 ) ? ' MAXVALUE ' . ( int )$this->objMax : ''; $objQuery = 'CREATE SEQUENCE ' . $this->objSequence . ' INCREMENT BY 1 START WITH 1 MINVALUE 1' . $objMax . ' NO CACHE'; return db2_exec( $this->objConnection, $objQuery ) or trigger_error( db2_stmt_errormsg(), E_USER_WARNING ); }