标签:需要 port bin begin style tns ora prot var_dump
//入参
$in1 = ‘2017-01-01‘; //必填
$in2 = ‘2017-08-01‘; //必填
$in3 = ‘‘; //选填
$tns = ‘(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = dbname) (SID = dbname)))‘;
$conn = oci_connect (‘user‘ , ‘password‘ ,$tns,‘utf8‘);
if (! $conn ) {
$e = oci_error ();
trigger_error ( htmlentities ( $e [ ‘message‘ ]), E_USER_ERROR );
}
$curs = oci_new_cursor($conn);
$stmt = oci_parse($conn, "begin PACKAGE_NAME.PROCEDURE_NAME(:IN1,:IN2,:IN3,:OUT1); end;");
oci_bind_by_name ( $stmt , ‘:IN1‘ , $in1 );
oci_bind_by_name ( $stmt , ‘:IN2‘ , $in2 );
oci_bind_by_name ( $stmt , ‘:IN3‘ , $in2 );
oci_bind_by_name($stmt, ":OUT1", $curs, -1, SQLT_RSET);
oci_execute($stmt);
oci_execute($curs,OCI_DEFAULT);
while (( $row = oci_fetch_row ( $curs )) != false ) {
var_dump($row);
}
oci_free_statement($stmt);
oci_free_statement($curs);
oci_close($conn);
红色部分需要注意
1,‘utf8‘注意字符集,如果入参中有中文,没有指定字符集,可能会影响结果。
2,:IN3虽然该参数为可选参数,调用时也为空字符串,但是调用时必须带上该参数,否则得不到想要的结果。
3,$curs, SQLT_RSET 注意出参的类型,存储过程中什么类型就用相应类类型去接收。
标签:需要 port bin begin style tns ora prot var_dump
原文地址:http://www.cnblogs.com/qy-brother/p/7454555.html