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