MSSQLIdGenerator.php

Go to the documentation of this file.
00001 <?php 00002 00003 require_once 'creole/IdGenerator.php'; 00004 00013 class MSSQLIdGenerator extends IdGenerator 00014 { 00016 var $conn; 00017 00023 function MSSQLIdGenerator(/*Connection*/ &$conn) 00024 { 00025 if (! is_a($conn, 'Connection')) { 00026 trigger_error( 00027 "MSSQLIdGenerator::MSSQLIdGenerator(): parameter 1 not of type 'Connection' !", 00028 E_USER_ERROR 00029 ); 00030 } 00031 00032 $this->conn =& $conn; 00033 } 00034 00038 function isBeforeInsert() 00039 { 00040 return false; 00041 } 00042 00046 function isAfterInsert() 00047 { 00048 return true; 00049 } 00050 00054 function getIdMethod() 00055 { 00056 return IdGenerator::AUTOINCREMENT(); 00057 } 00058 00063 function getId($unused = null) 00064 { 00065 $rs =& $this->conn->executeQuery("select @@identity", ResultSet::FETCHMODE_NUM()); 00066 if (Creole::isError($rs)) { return $rs; } 00067 $e = $rs->next(); 00068 if (Creole::isError($e)) { return $e; } 00069 return $rs->getInt(1); 00070 } 00071 00072 } 00073

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


Copyright © 2004 Hans Lellelid  
Creole[php4] CVS