2013-04-16 39 views
0

有人可以幫助我如何在PHP中通過oracle調用存儲過程嗎? 我有存儲過程如何在PHP中使用OCI8執行存儲過程

CREATE OR REPLACE PROCEDURE view_institution(
     c_dbuser OUT SYS_REFCURSOR) 
IS 
BEGIN 
    OPEN c_dbuser FOR 
    SELECT * FROM institution; 
END; 

用於顯示錶機構的所有記錄中的上述命名view_instituion存儲過程的樣品。有人可以教我在PHP中調用上述存儲過程。林新與存儲過程

感謝

+0

你使用PDO? –

+0

什麼是PDO? im new:( – user2234937

+0

PDO Basics:http://bit.ly/pdobasics –

回答

5

打如果使用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); 

如果使用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); 
+0

ohh ..我正在使用oci ..是這樣嗎? – user2234937

+0

<?php $ objConnect = oci_connect(「ccc」,「rrr」 ,「ff」);?> 這是我連接oracle數據庫的例子.. – user2234937

+0

以OCI爲例,我很久沒有使用過它,但我認爲它的權利是這樣的 –