1--TEST-- 2PDO MySQL auto_increment / last insert id 3--SKIPIF-- 4<?php 5if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded'); 6require __DIR__ . '/config.inc'; 7require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 8PDOTest::skip(); 9?> 10--FILE-- 11<?php 12require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 13$db = PDOTest::test_factory(__DIR__ . '/common.phpt'); 14 15print_r($db->query("CREATE TABLE test (id int auto_increment primary key, num int)")); 16 17print_r($db->query("INSERT INTO test (id, num) VALUES (23, 42)")); 18 19print_r($db->query("INSERT INTO test (num) VALUES (451)")); 20 21print_r($db->lastInsertId()); 22--EXPECT-- 23PDOStatement Object 24( 25 [queryString] => CREATE TABLE test (id int auto_increment primary key, num int) 26) 27PDOStatement Object 28( 29 [queryString] => INSERT INTO test (id, num) VALUES (23, 42) 30) 31PDOStatement Object 32( 33 [queryString] => INSERT INTO test (num) VALUES (451) 34) 3524 36