OCI8IdGenerator.php

Go to the documentation of this file.
00001 <?php 00002 00003 require_once 'creole/IdGenerator.php'; 00004 00012 class OCI8IdGenerator extends IdGenerator { 00013 00015 private $conn; 00016 00022 public function __construct(Connection $conn) 00023 { 00024 $this->conn = $conn; 00025 } 00026 00030 public function isBeforeInsert() 00031 { 00032 return true; 00033 } 00034 00038 public function isAfterInsert() 00039 { 00040 return false; 00041 } 00042 00046 public function getIdMethod() 00047 { 00048 return self::SEQUENCE; 00049 } 00050 00054 public function getId($name = null) 00055 { 00056 if ($name === null) { 00057 throw new SQLException("You must specify the sequence name when calling getId() method."); 00058 } 00059 $rs = $this->conn->executeQuery("select " . $name . ".nextval from dual", ResultSet::FETCHMODE_NUM); 00060 $rs->next(); 00061 return $rs->getInt(1); 00062 } 00063 00064 } 00065

This file is part of the Creole[php5] library.


Copyright © 2004 Hans Lellelid  
Creole[php5] CVS