MySQLIdGenerator Class Reference

Inheritance diagram for MySQLIdGenerator:

IdGenerator

List of all members.

Public Member Functions

 __construct (Connection $conn)
 Creates a new IdGenerator class, saves passed connection for use later by getId() method.
 isBeforeInsert ()
 isAfterInsert ()
 getIdMethod ()
 getId ($unused=null)
 Returns last-generated auto-increment ID.

Private Attributes

 $conn
 Connection object that instantiated this class.


Detailed Description

Definition at line 12 of file MySQLIdGenerator.php.


Constructor & Destructor Documentation

MySQLIdGenerator::__construct ( Connection conn  ) 

Creates a new IdGenerator class, saves passed connection for use later by getId() method.

Parameters:
Connection $conn

Definition at line 22 of file MySQLIdGenerator.php.

00023     {
00024         $this->conn = $conn;
00025     }


Member Function Documentation

MySQLIdGenerator::getId ( unused = null  ) 

Returns last-generated auto-increment ID.

Note that for very large values (2,147,483,648 to 9,223,372,036,854,775,807) a string will be returned, because these numbers are larger than supported by PHP's native numeric datatypes.

See also:
IdGenerator::getId()

Implements IdGenerator.

Definition at line 60 of file MySQLIdGenerator.php.

References $result.

00061     {
00062         $insert_id = mysql_insert_id($this->conn->getResource());
00063         if ( $insert_id < 0 ) {
00064             $insert_id = null;
00065             $result = mysql_query('SELECT LAST_INSERT_ID()', $this->conn->getResource());
00066             if ( $result ) {
00067                 $row = mysql_fetch_row($result);
00068                 $insert_id = $row ? $row[0] : null;
00069             }
00070         }
00071         return $insert_id;
00072     }

MySQLIdGenerator::getIdMethod (  ) 

See also:
IdGenerator::getIdMethod()

Implements IdGenerator.

Definition at line 46 of file MySQLIdGenerator.php.

00047     {
00048         return self::AUTOINCREMENT;
00049     }

MySQLIdGenerator::isAfterInsert (  ) 

See also:
IdGenerator::isAfterInsert()

Implements IdGenerator.

Definition at line 38 of file MySQLIdGenerator.php.

00039     {
00040         return true;
00041     }

MySQLIdGenerator::isBeforeInsert (  ) 

See also:
IdGenerator::isBeforeInsert()

Implements IdGenerator.

Definition at line 30 of file MySQLIdGenerator.php.

00031     {
00032         return false;
00033     }    


Member Data Documentation

MySQLIdGenerator::$conn [private]

Connection object that instantiated this class.

Definition at line 15 of file MySQLIdGenerator.php.


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

Generated on Wed May 6 23:10:50 2009 for fareofficelib by  doxygen 1.5.8