我正在从我的Web应用程序中将SQL从Couch DB转移到我的第一个应用程序.
虽然我不能说为什么我不喜欢SQL查询,但不确定我不喜欢,让CURL请求访问我的数据库声音的想法必须比使用PHP PDO更好.
我花了一天半的时间试图熟悉沙发DB HTTP API.我无法声称我已经彻底阅读了API,但是在开始编码之前谁彻底阅读了API.所以我的,可能是愚蠢的问题是 - how do I pass an variable other than doc to a map function while making a http request to the view.API清楚地说地图函数只接受一个"doc"参数,在这种情况下,下面的函数本身是错误的,但我找不到API中允许的任何部分我使用最终用户提供的输入查询数据库.
我的地图功能是
function(doc, pid2){
if (doc.pid === pid2)
{
emit(doc._id, doc) ;
}
}
Run Code Online (Sandbox Code Playgroud)
pid2是由前端用户提供的号码.
<?php
$pid2 = file_get_contents(facebook graphi api call_returns a Profile ID) ;
$user_exists = HTTP request to couch DB view to return
in JSON format the list of JSON documents with pid = $pid2
?>
Run Code Online (Sandbox Code Playgroud) 我在下面的最后一行收到"意外的输入结束"错误,如果我一次删除最后一行,则错误在最后一行显示.我正在尝试使用chrome.
我使用notepad ++,并没有抛出任何错误或建议.我试过jedit但是我不太确定在任何一种情况下是否有任何语法检查是活动的.N ++虽然给了我自动填充建议.
不知道这有什么问题.AJAX在测试时确实完成了两次,但突然停止工作.无法弄清楚是什么打破了这个.
<script type="text/javascript">
function postevac()
{
var location = document.getElementById("location").value ;
var nameno = document.getElementById("Nameno").value ;
var resources = document.getElementById("resources").value ;
var persons = document.getElementById("persons").value ;
var x = new XMLHttpRequest();
x.open("post", "http://localhost:5984/ch", true) ;
x.setRequestHeader("Content-type", "application/json") ;
var y = {
"location" : location ,
"nameno" : nameno ,
"resources" : resources ,
"persons" : persons ,
} ;
x.send(JSON.stringify(y)) ;
</script>
Run Code Online (Sandbox Code Playgroud)