我想通过SOAP wsdl创建用于更新数据库的Web服务 我尝试以下代码:
require_once('dbconn.php');
require_once('lib/nusoap.php');
$server = new nusoap_server();
function editBookData($id,$title,$author_name,$price,$isbn,$category){
global $dbconn;
$sql = "UPDATE books SET title = :title, author_name = :author_name, price=:price, isbn=:isbn, category= :category WHERE id= :id";
// prepare sql and bind parameters
$stmt = $dbconn->prepare($sql);
$stmt->bindParam(':id', $id);
$stmt->bindParam(':title', $title);
$stmt->bindParam(':author_name', $author_name);
$stmt->bindParam(':price', $price);
$stmt->bindParam(':isbn', $isbn);
$stmt->bindParam(':category', $category);
// insert a row
$stmt->execute();
// $data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$data="Update Success!";
return json_encode($data);
$dbconn = null;
}
$server->configureWSDL('booksServer', 'urn:book');
$server->register('editBookData',
array('id' => 'xsd:integer'), //parameter
array('data' => 'xsd:string'), //output
'urn:book', //namespace
'urn:book#editBookData' //soapaction
);
$server->service(file_get_contents("php://input"));
但似乎无法正常工作,我是SOAP API的新用户,可以解决这些问题吗?
答案 0 :(得分:-1)
我为这些错误的SQL查询字符串找到了解决方案。
$sql = "UPDATE books SET title = '$title', author_name = '$author_name', price='$price', isbn='$isbn', category= '$category' WHERE id= '$id'";