xref: /PHP-8.4/ext/pdo_pgsql/tests/bug72633.phpt (revision f4a5db3e)
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 test72633 (id SERIAL NOT NULL, field1 VARCHAR(10))');
22
23$stmt = $db->prepare("INSERT INTO test72633 (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('test72633_id_seq'));
35
36?>
37--CLEAN--
38<?php
39require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
40$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
41$db->query('DROP TABLE IF EXISTS test72633');
42?>
43--EXPECTREGEX--
44string\([0-9]*\)\ \"[0-9]*\"
45string\([0-9]*\)\ \"[0-9]*\"
46