|
PHP复制代码
$connection = array(
'UID' => 'username',
'PWD' => 'password',
'Database' => 'db_name',
'ConnectionPooling' => 1,
"CharacterSet" => 'utf-8',
'ReturnDatesAsStrings' => 1
);
$conn = sqlsrv_connect ("127.0.0.1", $connection);
$stmt = sqlsrv_query ($conn, "exec 存储过程名称 @canshu=100");
if ($stmt === false) {
echo "Error in executing statement 3.\n";
die(print_r(sqlsrv_errors (), true));
}
//存储过程中每一个select都会产生一个结果集,取某个结果集就需要从第一个移动到需要的那个结果集
//如果结果集为空就移到下一个
while (sqlsrv_has_rows ($stmt) !== TRUE) {
sqlsrv_next_result ($stmt);
}
$result_object = array();
while ($row = sqlsrv_fetch_object ($stmt)) {
$result_object[] = $row;
}
sqlsrv_free_stmt ($stmt);
sqlsrv_close ($conn);
return $result_object;
复制代码 使用CI的sqlsrv是无法运行有使用了游标的存储过程的,在sqlsrv的驱动中参数已经默认
PHP复制代码
return sqlsrv_query ($this->conn_id, $sql, null, array(
'Scrollable' => SQLSRV_CURSOR_STATIC ,//这个参数已经被写死了,具体含义可以参考sqlsrv的手册
'SendStreamParamsAtExec' => true
));
复制代码 |
评分
-
查看全部评分
|