xref: /PHP-7.2/ext/pdo_pgsql/tests/bug72633.phpt (revision d3a8e107)
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 dirname(__FILE__) . '/config.inc';
7require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8PDOTest::skip();
9?>
10--FILE--
11<?php
12
13require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
14
15$db = PDOTest::test_factory(dirname(__FILE__) . '/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