Insert data into one table from other 4

0

I have this code to insert data into the database, I would like to insert data from 4 tables into one. But consecutively, I tried that way only because it adds the same data to the last 3 tables and only changes the data from the first select. Would anyone help me?

$link = mysqli_connect('localhost','root','','teste2');
$link->set_charset("utf8");

$query = "SELECT * from review_store";
$select = mysqli_query($link, $query);

while($row = mysqli_fetch_array($select)){

$review_store= array(
$review_id_store = 'review_id_store'=>$row['review_id'],
$store_id_store = 'store_id_store'=>$row['store_id']//REVIEW_STORE
);


$queryx = "SELECT * from review_entity_summary";
$selectx = mysqli_query($link, $queryx);

$row = mysqli_fetch_array($selectx);

 $review_sumary= array(
$primary_id = 'primary_id'=>$row['primary_id'],
$entity_pk_value_summary = 'entity_pk_value_summary'=>$row['entity_pk_value'],
$entity_type = 'entity_type'=>$row['entity_type'],
$reviews_count = 'reviews_count'=>$row['reviews_count'],
$rating_summary = 'rating_summary'=>$row['rating_summary'],
$store_id_summary = 'store_id_summary'=>$row['store_id']//REVIEW_ENTITY_SUMMARY
);


$querys = "SELECT * from review_detail";
$selects = mysqli_query($link, $querys);


$row = mysqli_fetch_array($selects);

 $review_det= array(
$id = 'detail_id'=>$row['detail_id'],
$review_id = 'review_id_detail'=>$row['review_id'],
$store_id_detail = 'store_id_detail'=>$row['store_id'],
$title = 'title'=>$row['title'],
$detail = 'detail'=>$row['detail'],
$nickname = 'nickname'=>$row['nickname'],
$customer_id = 'customer_id'=>$row['customer_id']//REVIEW_DETAIL
);

$querya = "SELECT * from review";
$selecta = mysqli_query($link, $querya);

$row = mysqli_fetch_array($selecta);

$review = array(
$review_id = 'review_id'=>$row['review_id'],
$criadoem = 'criadoem'=>$row['created_at'],
$entity_id = 'entity_id'=>$row['entity_id'],
$entity_pk_value = 'entity_pk_value'=>$row['entity_pk_value'],
$status_id = 'status_id'=>$row['status_id']//REVIEW
);

print_r(array($review_store, $review_sumary, $review_det, $review)); 

$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$query = "INSERT INTO comentproduto ('primary_id', 'entity_pk_value_summary', 'entity_type', 'reviews_count', 'rating_summary', 'store_id_summary', 'review_id_store', 'store_id_store', 'detail_id', 'review_id_detail', 'store_id_detail', 'title', 'detail', 'nickname', 'customer_id', 'review_id', 'created_at', 'entity_id', 'entity_pk_value', 'status_id') VALUES ('".$review_store[$review_id_store]."', '".$review_store[$store_id_store]."', '".$review_sumary[$primary_id]."', '".$review_sumary[$entity_pk_value_summary]."', '".$review_sumary[$entity_type]."', '".$review_sumary[$reviews_count]."', '".$review_sumary[$rating_summary]."', '".$review_sumary[$store_id_summary]."', '".$review_det['detail_id']."', '".$review_det[$review_id]."', '".$review_det[$store_id_detail]."', '".$review_det['title']."', '".$review_det['detail']."', '".$review_det['nickname']."', '".$review_det['customer_id']."', '".$review['review_id']."', '".$review['criadoem']."', '".$review['entity_id']."', '".$review['entity_pk_value']."', '".$review['status_id']."')";
$connection->query($query);
}

How is being saved

First "spin"

[0] => Array
    (
        [review_id_store] => 7 //SOMENTE ESSES VALOR É ALTERADO
        [store_id_store] => 0 //SOMENTE ESSES VALOR É ALTERADO
    )

[1] => Array
    (
        [primary_id] => 26
        [entity_pk_value_summary] => 1028
        [entity_type] => 1
        [reviews_count] => 1
        [rating_summary] => 100
        [store_id_summary] => 2
    )

[2] => Array
    (
        [detail_id] => 1
        [review_id_detail] => 1
        [store_id_detail] => 1
        [title] => Ótimo! 
        [detail] => Adorei o buquê, muito lindo! 
        [nickname] => Débora 
        [customer_id] => 94
    )

[3] => Array
    (
        [review_id] => 1
        [criadoem] => 2016-07-13 12:54:07
        [entity_id] => 1
        [entity_pk_value] => 1042
        [status_id] => 1
    )

)

Second "spin"

[0] => Array
    (
      [review_id_store] => 7 //SOMENTE ESSES VALOR É ALTERADO
      [store_id_store] => 1 //SOMENTE ESSES VALOR É ALTERADO
    )

[1] => Array
    (
      [primary_id] => 26
      [entity_pk_value_summary] => 1028
      [entity_type] => 1
      [reviews_count] => 1
      [rating_summary] => 100
      [store_id_summary] => 2
    )

[2] => Array
    (
      [detail_id] => 1
      [review_id_detail] => 1
      [store_id_detail] => 1
      [title] => Ótimo! 
      [detail] => Adorei o buquê, muito lindo! 
      [nickname] => Débora 
      [customer_id] => 94
    )

[3] => Array
    (
      [review_id] => 1
      [criadoem] => 2016-07-13 12:54:07
      [entity_id] => 1
      [entity_pk_value] => 1042
      [status_id] => 1
    )

  )

As you can see, only the first values are changed, after all the data is routed, each line (1470) goes to the second one, so it does not leave the null fields only one by one by filling in the initial values in others.

    
asked by anonymous 16.11.2017 / 20:13

0 answers