我有以下SQL程序,当我执行它时,它适用于SQL Server Management studio
USE [DatabaseName]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[getRegisterSummaryReport]
@registerID = -1,
@StartBusinessDate = '1900-01-01 00:00:00',
@EndBusinessDate = '3000-01-01 00:00:00'
SELECT 'Return Value' = @return_value
GO
我现在想要的是从PHP函数传递StartBusinessDate和EndBusinessDate(抱歉,我是PHP的新手)。
这就是我所拥有的,但由于某种原因,我得到了错误的响应(我想我没有使用正确的方法将日期传递给我的SQL Server)。
public static function getRegisterSummary($registerId, $startBusinessDate, $endBusinessDate, $dbConnection){
$date_start = '1900-01-01 00:00:00';
$date_end = '3000-01-01 00:00:00';
if($startBusinessDate == "") $startBusinessDate = date('Y-m-d G:i:s', $date_start); // if startBusinessDate is "" I want the replace it with date_start
if($endBusinessDate == "") $endtBusinessDate = date('Y-m-d G:i:s', $date_end);
$sql = "exec [database1].[dbo].[getRegisterSummaryReport] @registerId = {$registerId}, @startBusinessDate = '{$startBusinessDate}', @endBusinessDate = '{$endBusinessDate}'";
$results = $dbConnection->query($sql);
if($results){
return $results;
}
return false;
}
谢谢
答案 0 :(得分:0)
好的,这很尴尬!!
首先我将语法更改为此
if($startBusinessDate == "") $startBusinessDate = date('1900-01-01');
if($endBusinessDate == "") $endBusinessDate = date('3000-01-01');
出于某种原因,这与我合作并传递了正确的价值,这与我添加
时不同日期(' Y-m-d G:我:s',$ date_start);
我在
中犯了一个错误if($ endBusinessDate =="")$ endtBusinessDate = date(' Y-m-d G:i:s',$ date_end);
我在$ endtBusinessDate之后添加了:(