首先,我想告訴你,我沒有興趣與PHP框架,如phpillow解決方案,PHP-ON-沙發,下垂或相似。我想創建一個連接到CouchDB 專有與cURL在PHP文件中,如下例所示。CouchDB與PHP(使用cURL),但如何?
1例:
<?php
// Get a list of databases
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost:5984/_all_dbs');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: application/json',
'Accept: */*'
));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
示例2:
<?php
// Get a document 'customer' from specific db 'customers'
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost:5984/customers/customer');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: application/json',
'Accept: */*'
));
curl_setopt($ch, CURLOPT_USERPWD, 'myDBusername:myDBpass');
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
我知道什麼事這麼遠嗎?我知道如何在PHP文件中使用cURL創建CRUD(創建,讀取,更新,刪除),以上例子。我知道如何從命令提示符使用cURL。
我向你問到什麼?我問你以下幾點:
如何使用cURL在PHP文件中使用CouchDB視圖創建(複雜)搜索?
如何使用HTML表單中的一些輸入信息創建複雜搜索?
請問*爲什麼*你不」不想使用現有的庫?這當然會有它的優勢。 – Biffen 2014-12-09 12:40:08
雖然我不是Couch專家,但cURL用於發出HTTP請求。它不用於創建視圖。您需要以某種方式從您的CRUD請求中呈現HTML。 – 2014-12-09 13:29:14
我正處於學習階段,我想知道當我提出一些疑問時究竟發生了什麼。 – Pajsije 2014-12-09 13:34:39