1--TEST-- 2PDO PgSQL Bug #72633 (Postgres PDO lastInsertId() should work without specifying a sequence) 3--SKIPIF-- 4<?php 5if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded'); 6require __DIR__ . '/config.inc'; 7require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 8PDOTest::skip(); 9?> 10--FILE-- 11<?php 12 13require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 14 15$db = PDOTest::test_factory(__DIR__ . '/common.phpt'); 16 17$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); 18 19$db->query('CREATE TABLE test_last_id (id SERIAL NOT NULL, field1 VARCHAR(10))'); 20 21$stmt = $db->prepare("INSERT INTO test_last_id (field1) VALUES ('test')"); 22 23$stmt->execute(); 24 25/** 26 * No sequence name informed 27 */ 28var_dump($db->lastInsertId()); 29/** 30 * Sequence name informed 31 */ 32var_dump($db->lastInsertId('test_last_id_id_seq')); 33 34$db->query('DROP TABLE test_last_id'); 35 36?> 37--EXPECTREGEX-- 38string\([0-9]*\)\ \"[0-9]*\" 39string\([0-9]*\)\ \"[0-9]*\" 40