congress = (int) $doc['session']; $bill->billtype = (string) $doc['type']; $bill->number = (int) $doc['number']; $bill->introduced = (int) $doc->introduced['date']; //// including all the titles $titles = array(); foreach ($doc->titles->title as $title) { $titles[] = (string) $title; } $bill->titles = $titles; //// look up the primary and co-sponsors $bill->sponsor_rep_id = $doc->sponsor['id']; $sponsors = array(); foreach ($doc->cosponsors->cosponsor as $sponsor) { $sponsors[(int) $sponsor['id']] = strtotime((string) $sponsor['joined']); } $bill->sponsors = $sponsors; //// persist to database $bill->save(); echo "{$bill->congress} {$bill->billtype} {$bill->number} done.\n"; } if (isset($_SERVER['argv'])) { if ($_SERVER['argv'][0] != 'bill.php') { return; } if (count($_SERVER['argv']) > 1) { //// parse arguments } else { //// process all current congress bills in the data dir $current = get_current_congress_session(); $bills_dir = $data_dir ."/us/{$current['congress']}/bills"; $listing = scandir($bills_dir); foreach ($listing as $filename) { $path ="{$bills_dir}/{$filename}"; if (is_file($path)) { parseBill($path); } } } } ?>