I followed the manual, tutorials, etc and EVENTUALLY managed to find the problem but still cannot understand why the following script is working:
$conn->beginTransaction(); // $conn->commit(); $stmt = $conn->prepare ( " INSERT INTO `booksDasa` ( `ref`, `author`, `memo`, `type`, `baht`, `qqq` ) VALUES ( ?,?,?,?,?,? ) " ); $imax = 0; foreach($aInserts as $id => $aFails): $aWorks = ; foreach($aFails as $id2 => $tmp): $aWorks = $tmp; endforeach; // SHOW FIRST ITEM ONLY if($id): // DO NOTHING else: prettyShow($aFails, '$aFails'); prettyShow($aWorks, '$aWorks'); endif; $ok = $stmt->execute( $aWorks ); $imax++; if($imax >= 2): break; endif; endforeach; $ok = $conn->commit();
In case you didn’t notice the passed $aWorks array has numeric array keys whereas the aFailed array uses named keys.
I would have thought the passed data was the same. Is this a bug?