Gc\Db\AbstractTable::getLastInsertId PHP Méthode

getLastInsertId() public méthode

Get last insert id
public getLastInsertId ( string $tableName = null ) : integer
$tableName string Optional table name
Résultat integer
    public function getLastInsertId($tableName = null)
    {
        $tableName = empty($tableName) ? $this->name : $tableName;
        if ($this->getDriverName() == 'pdo_pgsql') {
            $row = $this->fetchRow(sprintf("SELECT currval('%s_id_seq') AS value", $tableName));
            return $row['value'];
        }
        return $this->getAdapter()->getDriver()->getConnection()->getLastGeneratedValue($tableName);
    }

Usage Example

Exemple #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testGetLastInsertId()
 {
     $this->assertInternalType('integer', (int) $this->object->getLastInsertId());
 }