我们说我有一张桌子
测试
id(int)| foo varchar(255)
如果我这样做:
$query = "INSERT INTO test (foo) VALUES (?),(?);";
$stmt = $mysqli->prepare($query);
$stmt->bind_param('ss','foo','bar');
$stmt->execute();
$last = $mysqli->insert_id;
$query_ir = "SELECT * FROM test WHERE id<=? ORDER BY id DESC LIMIT 0,2";
$stmt_ir = $mysqli->prepare($query_ir);
$stmt_ir->bind_param('i',$last);
$stmt_ir->execute();
我是否确定我会获得第一个查询插入的2条记录,或者是否有(甚至是最小的)机会比另一条查询在两个插入之间添加一行?