帮助了解哪里出了问题。
重点是:
包括缓冲,创建 XML 数据:
ob_start(); header("Content-Type: text/xml"); header("Expires: Thu, 19 Feb 1998 13:24:18 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: post-check=0,pre-check=0"); header("Cache-Control: max-age=0"); header("Pragma: no-cache"); echo "<?xml version=\"1.0\" encoding=\"WINDOWS-1251\" standalone=\"yes\"?>"; echo "<MAIN>"; echo "<ROWSET>"; echo "<ROW>"; echo "<CODE>somecode</CODE>"; echo "<DESC>somedesc</DESC>"; echo "<NOMINAL>somenominal</NOMINAL>"; echo "<DATE>2012.01.01</DATE>"; echo "<TYPE>sometype</TYPE>"; echo "</ROW>"; echo "</ROWSET>"; echo "</MAIN>";
将缓冲区的内容放入变量
content
中,刷新缓冲区并关闭缓冲。$content = ob_get_contents(); ob_end_clean();
连接数据库,调用函数,传递
content
保存我写的代码,取自官方手册,可能不是这样)。error_reporting(E_ALL); ini_set('display_errors',1); header('Content-Type: text/xml; charset=windows-1251'); $c=oci_connect("test_user", "test_schema", "DBtest"); $rclob = oci_new_descriptor($c, OCI_D_LOB); $clob = oci_new_descriptor($c, OCI_D_LOB); $s = oci_parse($c, "begin :ret:=create_sm.get_xml_data(:data, :out); end;"); oci_bind_by_name($s, ":data", $clob, -1, OCI_B_CLOB); oci_bind_by_name($s, ":ret", $rclob, -1, OCI_B_CLOB); oci_bind_by_name($s, ":out", $out, 1000); $clob->writeTemporary($content); $r = oci_execute($s, OCI_DEFAULT); // use OCI_DEFAULT so $lob->save() works //$e = oci_error($s); //var_dump($e); oci_commit($c); //echo $out; $returnvalues = convertDateBackwards($rclob->load()); $returnvalues = str_replace("<SECURITY>","<SECURITY ret=\"".$out."\">",$returnvalues); //echo convertDateBackwards($rclob->load()); echo $returnvalues; $clob->free(); // close LOB descriptor to free resources $rclob->free(); // close LOB descriptor to free resources oci_free_statement($s); oci_close($c);
错误出现在这个:
Warning: oci_execute() [function.oci-execute]:
ORA-06550: line 1, column 14:
PLS-00201: identifier 'CREATE_SM.GET_XML_DATA' must be declared
ORA-06550: line 1, column 7: PL / SQL: Statement ignored in C:\webserver\www.site.ru\www\blocks\create_xml.php on line 57
Fatal error: Call to undefined function convertDateBackwards() in C:\webserver\www.site.ru\www\blocks\create_xml.php on line 62