Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. <?php
  2.  
  3. $pathToFile = $_POST['file'];
  4. $dataFromFile = file($pathToFile);
  5.  
  6. $pdo = new \PDO('dsn');
  7.  
  8. foreach ($dataFromFile as $line) {
  9. $pdo->exec("INSERT INTO test_table (val1, val2) VALUES ($line[1], $line[2])");
  10.  
  11. if (!empty($line[1])) {
  12. $items = $pdo->query("SELECT * FROM test_table2 WHERE any_filed=$line[1]")
  13. ->fetchAll();
  14.  
  15. foreach ($items as $item) {
  16. $children = $pdo->query("SELECT * FROM test_table3 WHERE filed={$item['name']}")
  17. ->fetchAll();
  18.  
  19. $pdo->exec("INSERT INTO test_logs (val1, val2) VALUES ($children[0], $children[1])");
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement