oracle 如何在 PHP 中使用 OCI8 执行存储过程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16037569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to execute a stored procedure using OCI8 in PHP
提问by user2234937
Can someone help me on how to call the stored procedure in oracle by php? I have the sample of stored procedure
有人可以帮助我如何通过 php 在 oracle 中调用存储过程吗?我有存储过程的样本
CREATE OR REPLACE PROCEDURE view_institution(
c_dbuser OUT SYS_REFCURSOR)
IS
BEGIN
OPEN c_dbuser FOR
SELECT * FROM institution;
END;
the above stored procedure named view_instituion used to display all record on table institution. Can someone teach me to call the above stored procedure in php. Im new on playing with stored procedure
上面名为 view_instituion 的存储过程用于显示表机构上的所有记录。有人可以教我在php.ini中调用上面的存储过程吗?我刚开始玩存储过程
thanks
谢谢
回答by S.Visser
If you use the PDO engine
如果您使用 PDO 引擎
/* Define output */
$output = "";
/* The call */
$foo = $pdo->prepare("CALL view_institution(?)");
/* Binding Parameters */
$foo->bindParam($parameter1, $output);
/* Execture Query */
$foo->execute();
/* Get output on the screeen */
print_r($output, true);
If you use oci
如果你使用 oci
/* The call */
$sql = "CALL view_institution(:parameter)";
/* Parse connection and sql */
$foo = oci_parse($conn, $sql);
/* Binding Parameters */
oci_bind_by_name($foo, ':parameter', $yourparameter) ;
/* Execute */
$res = oci_execute($foo);
/* Get the output on the screen */
print_r($res, true);