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?> 23--EXPECT-- 24PDOStatement Object 25( 26 [queryString] => CREATE TABLE test (id int auto_increment primary key, num int) 27) 28PDOStatement Object 29( 30 [queryString] => INSERT INTO test (id, num) VALUES (23, 42) 31) 32PDOStatement Object 33( 34 [queryString] => INSERT INTO test (num) VALUES (451) 35) 3624 37