On MySQL 5.1.47, PHP 5.2.14
I have looked at every PHP and MySql website I can find, and I'm sure my syntax must be incorrect, but I don't know how, why, or where. All I want to do is put this information in a transaction. Many queries are being run, and I don't want one failure to screw up everything else. You'll notice that there aren't many queries here... most of them are in the classes themselves. Maybe that matters; not sure.
Anyway, for testing purposes I'm simply calling ROLLBACK at the end of all this. Alas, nothing is rolled back, and all the queries succeeded in adding information to the DB. Because of this, I'm convinced my transaction syntax is wrong. I've tried many ways, and this just happens to be the current syntax. Please help!
mysql_query( 'SET AUTOCOMMIT=0' );
mysql_query( 'BEGIN' );
$cust->findIdOrAdd( $adrs );
// add the order to the db
$order->add();
// before adding products, we need to map the skus to ids
$skumap = array();
$sql = 'select sku, id from products';
$result = mysql_query( $sql );
while ( $data = mysql_fetch_assoc( $result ) ) {
$skumap[ $data[ 'sku' ] ] = $data[ 'id' ];
}
// loop through all the items. set the orderid and custid,
// and then call the add function, passing in the skumap
foreach ( $order->products as $product ) {
$product->add( $skumap );
}
mysql_query( 'ROLLBACK' );
mysql_query( 'SET AUTOCOMMIT=1' );