2010-12-03 63 views

回答

8

閱讀mssql_execute()

$conn = mssql_connect($host, $user, $pass); 
mssql_select_db('somedb', $conn); 

// Call a simple query 
$result = mssql_query('SELECT * FROM sometable', $conn); 

// Release the result resource 
mssql_free_result($result); 

// Then execute the procedure 
$proc = mssql_init('some_proc', $conn); 
$proc_result = mssql_execute($proc); 

// Etc... 
mssql_free_statement($proc); 

編輯

閱讀odbc_exec()

$conn = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password); 
$exec = odbc_exec($conn, "CALL storedProc()"); 

,並從php.net文檔一個很好的例子:

實例

實施例#1 odbc_execute()odbc_prepare()例如在 下面的代碼,$成功將只 TRUE,如果所有三個參數MYPROC 是IN參數:

$a = 1; 
$b = 2; 
$c = 3; 
$stmt = odbc_prepare($conn, 'CALL myproc(?,?,?)'); 
$success = odbc_execute($stmt, array($a, $b, $c)); 

如果您需要調用使用INOUT或OUT 參數的存儲 過程中,建議的解決方法 是使用原生擴展您 數據庫(例如,MSSQL爲MS SQL Server或OCI8用於Oracle)。

+0

我使用的是odbc_connect.Is有可能在使用odbc連接時使用SP。 – Deepak 2010-12-03 10:45:59

相關問題