简体   繁体   English

如何在php上执行sql server存储过程?

[英]how to execute sql server stored procedure on php?

i want to know why i cannot call any stored procedure on php file it always return false but when i call it on sql server directly, it shows my data 我想知道为什么我不能在php文件上调用任何存储过程,但总是返回false,但是当我直接在sql server上调用它时,它显示了我的数据

here is my php: 这是我的PHP:

include ($_SERVER['DOCUMENT_ROOT'] . '/simda/classes/koneksi.php');
global $conn;
$kon = new koneksi();
$conn = $kon->bukaKoneksi();
$params = array();
$query = "EXEC dbo.RptSPJ_Pengeluaran '2013','1','1','1','0','1','1'";

$options = array("Scrollable" => SQLSRV_CURSOR_KEYSET);
$rs_test = sqlsrv_query($conn, $query, $params, $options);
if ($rs_test != NULL) {
    $num_rows = sqlsrv_num_rows($rs_test);
    echo $num_rows;
}
else {
    echo 'wrong';
}

if i echo the query and execute it on sql server, it shows my data is there anything wrong? 如果我回显查询并在sql server上执行它,则表明我的数据有问题吗? please help me thank you 请帮我谢谢

read this articles 阅读这篇文章

<?php
$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);
?>

the see this also 也看到这个

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

read these one;; 阅读这些 two ;; 两个 ;;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM