-1
방금 삽입 한 autoincrement 필드에 대한 insert_id를 가져 오는 스크립트가 있습니다.msqli db insert id가 올바른 값을 제공하지 않음
$db = new mysqli("localhost", "user", "pass", "db");
for($xx=0;$xx<$quantity;$xx++){
//quantity is the total number of tickets bought
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
//exit();
}
$payer_email = $db->real_escape_string($payer_email);
$name = $db->real_escape_string($name);
$query = "INSERT INTO `ticketsConference2013` VALUES (NULL, '".$payer_email."', '".$name."', null)";
$db->query($query);
$ticketIdIs="";
$ticketIdIs = $db->insert_id;
$html.='<p style="text-align:center;line-height:100%">Ticket number'.$ticketIdIs.'</p>';
$textIs = $name." ".($xx+1)." of ".$quantity;
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->Cell(0, 0, 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9', 0, 1);
$pdf->write1DBarcode($textIs, 'C39', '', '', '', 18, 0.4, $style, 'N');
}
$db->close();
데이터베이스에 정상적으로 삽입되지만 실행될 때마다 삽입 ID는 초기 삽입 번호 만 제공합니다. 데이터베이스의 실제 삽입 번호를 반영하지 않습니다.
나는 이것에 대해 조금 읽었습니다하지만 난 할 수 없습니다 fidling에도 불구하고 그것은