<?php

require_once "db.php";

$json = file_get_contents("uae_civil_procedure_42_2022_articles.json");
$data = json_decode($json,true);

$stmt = $pdo->prepare("
INSERT INTO legal_articles
(source_type,source_title,law_name,law_number,law_year,article_number,article_title,article_text)
VALUES (?,?,?,?,?,?,?,?)
");

foreach($data as $row){

$stmt->execute([
$row['source_type'],
$row['source_title'],
$row['law_name'],
$row['law_number'],
$row['law_year'],
$row['article_number'],
$row['article_title'],
$row['article_text']
]);

}

echo "تم استيراد جميع المواد بنجاح";