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 12 of file MySQLIdGenerator.php.
MySQLIdGenerator::__construct | ( | Connection $ | conn | ) |
Creates a new IdGenerator class, saves passed connection for use later by getId() method.
Connection | $conn |
Definition at line 22 of file MySQLIdGenerator.php.
00023 { 00024 $this->conn = $conn; 00025 }
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.
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 | ( | ) |
Implements IdGenerator.
Definition at line 46 of file MySQLIdGenerator.php.
MySQLIdGenerator::isAfterInsert | ( | ) |
Implements IdGenerator.
Definition at line 38 of file MySQLIdGenerator.php.
MySQLIdGenerator::isBeforeInsert | ( | ) |
Implements IdGenerator.
Definition at line 30 of file MySQLIdGenerator.php.
MySQLIdGenerator::$conn [private] |