couch_read.php
#! /usr/bin/php
<?php
// ------------------------------------------------------------------
// couch_read.php
//
// Jul/31/2020
//
// ------------------------------------------------------------------
include('Requests/library/Requests.php');
fputs (STDERR,"*** 開始 ***\n");
Requests::register_autoloader();
$url = 'http://localhost:5984/nagano/_all_docs?include_docs=true';
$request = Requests::get($url, array('Accept' => 'application/json'));
// var_dump($request->status_code);
$json_string = $request->body;
$data_aa = json_decode ($json_string,true);
$rows = $data_aa['rows'];
foreach ($rows as $unit)
{
$key = $unit['key'];
$unit_aa = $unit['doc'];
$str_out = $key . "\t" . $unit_aa["name"];
$str_out .= "\t" . $unit_aa["population"];
$str_out .= "\t" . $unit_aa["date_mod"];
print "$str_out\n";
}
fputs (STDERR,"*** 終了 ***\n");
// ------------------------------------------------------------------
実行
/couch_read.php