MySQLiIdGenerator Class Reference

Inheritance diagram for MySQLiIdGenerator:

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 31 of file MySQLiIdGenerator.php.


Constructor & Destructor Documentation

MySQLiIdGenerator::__construct ( Connection conn  ) 

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

Parameters:
Connection $conn

Definition at line 40 of file MySQLiIdGenerator.php.

00041     {
00042         $this->conn = $conn;
00043     }


Member Function Documentation

MySQLiIdGenerator::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 78 of file MySQLiIdGenerator.php.

References $result.

00079     {
00080         $resource = $this->conn->getResource();
00081         $insert_id = mysqli_insert_id($resource);
00082 
00083         if ( $insert_id < 0 ) {
00084             $insert_id = null;
00085 
00086             $result = mysqli_query($resource, 'SELECT LAST_INSERT_ID()');
00087 
00088             if ( $result ) {
00089                 $row = mysqli_fetch_row($result);
00090                 $insert_id = $row ? $row[0] : null;
00091             }
00092         }
00093 
00094         return $insert_id;
00095     }

MySQLiIdGenerator::getIdMethod (  ) 

See also:
IdGenerator::getIdMethod()

Implements IdGenerator.

Definition at line 64 of file MySQLiIdGenerator.php.

00065     {
00066         return self::AUTOINCREMENT;
00067     }

MySQLiIdGenerator::isAfterInsert (  ) 

See also:
IdGenerator::isAfterInsert()

Implements IdGenerator.

Definition at line 56 of file MySQLiIdGenerator.php.

00057     {
00058         return true;
00059     }

MySQLiIdGenerator::isBeforeInsert (  ) 

See also:
IdGenerator::isBeforeInsert()

Implements IdGenerator.

Definition at line 48 of file MySQLiIdGenerator.php.

00049     {
00050         return false;
00051     }


Member Data Documentation

MySQLiIdGenerator::$conn [private]

Connection object that instantiated this class.

Definition at line 33 of file MySQLiIdGenerator.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