Не соображу.. так не работает..
if(isset($data['complectation'])){
foreach ($data['complectation'] as $complectation) {
$this->db->query("INSERT INTO " . DB_PREFIX . "complectation SET product_id = '" . (int)$product_id . "', name = '" . $complectation['name'] . "', sort_order = '" . (int)$complectation['sort_order'] . "'");
$name_id = mysql_insert_id(); // По идее после инсерта добавляю в переменную последний id, а ниже подставляю эт переменную..
if(isset($data['complectation_image'])){
foreach ($data['complectation_image'] as $complectation_image) {
$this->db->query("INSERT INTO " . DB_PREFIX . "complectation_image SET product_id = '" . (int)$product_id . "', name_id = '" . (int)$name_id . "', image = '" . $this->db->escape(html_entity_decode($complectation_image['image'], ENT_QUOTES, 'UTF-8')) . "', complectation_description = '" . $complectation_image['complectation_description'] . "', complectation_price = '" . (float)$complectation_image['complectation_price'] . "', sort_order = '" . (int)$complectation_image['sort_order'] . "'");
}
}
}
}