Exemple #1
0
function readJson($jsonfile, $db)
{
    $str = file_get_contents($jsonfile);
    $json = json_decode($str, true);
    //print_r ($json);
    $bill = new Bill($json);
    //print $bill->toString();
    if ($bill->link_id === "") {
        echo "Bill ID Needed for {$entry}!";
        exit(-1);
    }
    $bill->insert($db);
    // Let's work on the actors
    foreach ($json['proposers'] as $a) {
        $actor = new Actor($a);
        $actor->is_proposer = 1;
        $actor->is_representative = is_representative($actor->name, $json['status_infos']);
        $actor->insert($db);
        $actor->insertCoActor($db, $bill->id);
        //print $actor->toString() . "\n";
    }
    foreach ($json['withdrawers'] as $a) {
        $actor = new Actor($a);
        $actor->is_withdrawer = 1;
        $actor->insert($db);
        $actor->insertCoActor($db, $bill->id);
        //print $actor->toString() . "\n";
    }
}