<?php
require_once "db.php";

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

$lawTitle = "قانون الإجراءات المدنية";
$lawNumber = 42;
$lawYear = 2022;

$stmt = $pdo->prepare("
INSERT INTO uae_laws
(law_title,law_number,law_year,article_number,article_text)
VALUES (?,?,?,?,?)
");

$count = 0;

foreach($data as $row){

    $stmt->execute([
        $lawTitle,
        $lawNumber,
        $lawYear,
        $row['article_number'],
        $row['text']
    ]);

    $count++;
}

echo "تم إدخال $count مادة بنجاح";