in reply to Re: foreach and lists
in thread foreach and lists

And of course once you have done that you will be able to move the prepare outside the loop while keeping the execute inside the loop. This is where a lot of the efficiency of prepared statement handles comes in.

$query = $dbh->prepare('INSERT INTO products_attributes (products_id, +options_id, options_values_id, options_values_price, price_prefix, pr +oducts_options_sort_order) VALUES (?, ?, ?, ?, ?, ?)'); foreach $line (@nametape) { .... $query->execute($products_id, $options_id, $options_values_id, $op +tions_values_price, $price_prefix, $products_options_sort_order) or e +xit 1; }

Think about other things such as the assignment of $options_id which could be moved outside the loop as well.

Replies are listed 'Best First'.
Re^3: foreach and lists
by almoodie (Initiate) on Mar 14, 2013 at 14:51 UTC
    Thank you everyone for your help, I now have my script working.