public function lastInsertId($table)
    {
        /*
         * We make an assumption that the sequence name for this table
         * is based on how postgres names sequences for SERIAL columns
         */

        $sequenceName = $this->getQuotedName($table . '_id_seq');
        $lastSequence = null;

        try {
            $lastSequence = $this->getDbh()->lastInsertId($sequenceName);
        } catch (\PDOException $e) {
            // in this case, the sequence name might be combined with the primary key name
        }

        // here we check if for instance, it's something like table_primary_key_seq instead of table_id_seq
        // this could occur when you use some kind of import tool like pgloader
        if (!$lastSequence) {
            $primaryKeys = $this->getPrimaryKey($table);
            $pkName = array_shift($primaryKeys);
            $lastSequence = $this->getDbh()->lastInsertId($this->getQuotedName($table . '_' . $pkName . '_seq'));
        }

        return $lastSequence;
    }
public function lastInsertId($table)
    {
        /*
         * We make an assumption that the sequence name for this table
         * is based on how postgres names sequences for SERIAL columns
         */

        $sequenceName = $this->getQuotedName($table . '_id_seq');
        $lastSequence = null;

        try {
            $lastSequence = $this->getDbh()->lastInsertId($sequenceName);
        } catch (\PDOException $e) {
            // in this case, the sequence name might be combined with the primary key name
        }

        // here we check if for instance, it's something like table_primary_key_seq instead of table_id_seq
        // this could occur when you use some kind of import tool like pgloader
        if (!$lastSequence) {
            $primaryKeys = $this->getPrimaryKey($table);
            $pkName = array_shift($primaryKeys);
            $lastSequence = $this->getDbh()->lastInsertId($this->getQuotedName($table . '_' . $pkName . '_seq'));
        }

        return $lastSequence;
    }
public function lastInsertId ( $ table ) { /*
         * We make an assumption that the sequence name for this table
         * is based on how postgres names sequences for SERIAL columns
         */ $ sequenceName = $ this -> getQuotedName ( $ table . '_id_seq' ) ; $ lastSequence = null ; try { $ lastSequence = $ this -> getDbh ( ) -> lastInsertId ( $ sequenceName ) ; } catch ( \ PDOException $ e ) { // in this case, the sequence name might be combined with the primary key name } // here we check if for instance, it's something like table_primary_key_seq instead of table_id_seq // this could occur when you use some kind of import tool like pgloader if ( ! $ lastSequence ) { $ primaryKeys = $ this -> getPrimaryKey ( $ table ) ; $ pkName = array_shift ( $ primaryKeys ) ; $ lastSequence = $ this -> getDbh ( ) -> lastInsertId ( $ this -> getQuotedName ( $ table . '_' . $ pkName . '_seq' ) ) ; } return $ lastSequence ; }
Get the last inserted ID of table.
Get the last inserted ID of table .