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. |
Definition at line 31 of file MySQLiIdGenerator.php.
MySQLiIdGenerator::__construct | ( | Connection $ | conn | ) |
Creates a new IdGenerator class, saves passed connection for use later by getId() method.
Connection | $conn |
Definition at line 40 of file MySQLiIdGenerator.php.
00041 { 00042 $this->conn = $conn; 00043 }
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.
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 | ( | ) |
Implements IdGenerator.
Definition at line 64 of file MySQLiIdGenerator.php.
MySQLiIdGenerator::isAfterInsert | ( | ) |
Implements IdGenerator.
Definition at line 56 of file MySQLiIdGenerator.php.
MySQLiIdGenerator::isBeforeInsert | ( | ) |
Implements IdGenerator.
Definition at line 48 of file MySQLiIdGenerator.php.
MySQLiIdGenerator::$conn [private] |
Connection object that instantiated this class.
Definition at line 33 of file MySQLiIdGenerator.php.