Web Analytics
 Function Query CouchDB Laravel

Function Query CouchDB Laravel


 

use GuzzleHttp\Client;

use GuzzleHttp\Psr7\Request;


 

function query($table, $field, $urut, $limit)

{

$field = json_encode($field);

//dd($field);

$client = new Client();

$headers = [

'Content-Type' => 'application/json'

];

$body = '{

"selector": {

"table": "' . $table . '",

"data": ' . $field . '

},

"sort": [

{

"data.urut": "' . $urut . '"

}

],

"limit": ' . $limit . ',

"skip": 0,

"execution_stats": true

}';

//dd(server());

$request = new Request('POST', '' . server() . '/_find', $headers, $body);

$res = $client->sendAsync($request)->wait();

$json = $res->getBody();

$json = json_decode($json, true);

$data = $json["docs"];

// dd($data);

 

return $data;

}


 

function query_umum($q)

{

// $field = json_encode($field);

//dd($field);

$client = new Client();

$headers = [

'Content-Type' => 'application/json'

];

$body = $q;

//dd(server());

$request = new Request('POST', '' . server() . '/_find', $headers, $body);

$res = $client->sendAsync($request)->wait();

$json = $res->getBody();

$json = json_decode($json, true);

$data = $json["docs"];

// dd($data);

 

return $data;

}

 


Lanjut Part : 1
Jam : 19:51:31
Durasi Part : 0:0:1
Durasi Total : 0:0:1

Punya Pertanyaan , Silahkan Whatsapp Langsung
Muhammad Ullil Fahri
WA : 089696380422
Tautan WA : https://wa.me/message/SG4YA2XQP5FPE1
Theme Customizer

Theme Styles