$sql = "Declare @v1 varchar(5000)";
$sql .= "Declare @v2 varchar(5000)";
$sql .= "Set @v1 = '";
$sql .= "<?xml version = \"1.0\"?>";
$sql .= "<Var1Data>";
$sql .= "<BodoOrder>";
$sql .= "<OrderNo>2016121201380</OrderNo>";
$sql .= "<Bodtype>订单</BodType>";
$sql .= "<xdate>2016-12-12</xdate>";
$sql .= "<DID>00</DID>";
$sql .= "<CID>104179</CID>";
$sql .= "<Contacter>111</Contacter>";
$sql .= "<Tel>13707165174</Tel>";
$sql .= "<address>测试地址</address>";
$sql .= "<BodNote>测试</BodNote>";
$sql .= "</BodoOrder>";
$sql .= "</Var1Data>'";
$sql .= "Set @v2 = '";
$sql .= "<?xml version = \"1.0\"?>";
$sql .= "<Var2Data>";
$sql .= "<BodoOrderDetails>";
$sql .= "<PID>14241</PID>";
$sql .= "<Color>金色</Color>";
$sql .= "<Size>90C</Size>";
$sql .= "<nQty>1</nQty>";
$sql .= "<nPrice>188.00</nPrice>";
$sql .= "</BodoOrderDetails>";
$sql .= "</Var2Data>'";
$sql .= "Exec LW2DRP @v1,@v2";
try {
$stmt = $dbh->prepare($sql);
$stmt->execute();
} catch (Exception $e) {
echo $e->getMessage();
}
报错:
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[42000]: Syntax error or access violation: 102 [Microsoft][SQL Server Native Client 11.0][SQL Server]'' 附近有语法错误。
但是我把 命令输出以后 ,直接放到数据库去执行,是可以成功的。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.