我尝试运行包含局部变量和循环的查询。 但是Fusio / Doctrine在执行时返回空/错误。
示例(空结果或布尔值):
$sum = $connection->fetchAll("declare @dateFrom DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(DATEADD(m, -1, GETDATE() - 2)) ), DATEADD(m, -1, GETDATE() - 1)));
declare @dateTo DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(GETDATE()) ), GETDATE()));
declare @dateFromtmp DATETIME=@dateFrom;
declare @tmpDate table(Dates DATETIME);
WHILE (@dateFromtmp <= @dateTo)
BEGIN
insert into @tmpDate values(@dateFromtmp)
SET @dateFromtmp = DATEADD( DAY,1,@dateFromtmp)
END;
SELECT @dateFrom;
");
$type = "is " . gettype($sum);
$count = count($sum);
return $response->build(200, [], [
'type'=>$type,
'count'=>$count,
'summary' => $sum,
]);
返回:
{
"type": "is array",
"count": 0,
"summary": []
}
在查询下面运行没有问题:
$sum = $connection->fetchColumn("declare @dateFrom DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(DATEADD(m, -1, GETDATE() - 2)) ), DATEADD(m, -1, GETDATE() - 1)));
declare @dateTo DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(GETDATE()) ), GETDATE()));
declare @dateFromtmp DATETIME=@dateFrom;
declare @tmpDate table(Dates DATETIME);
SELECT @dateFrom;
");
$type = "is " . gettype($sum);
$count = count($sum);
return $response->build(200, [], [
'type'=>$type,
'count'=>$count,
'summary' => $sum,
]);
返回:
{
"type": "is string",
"count": 1,
"summary": "2017-08-01 00:00:00.000"
}
我怀疑这与循环有关。 有没有办法在Fusio中运行此查询。?
由于
答案 0 :(得分:0)
在这里找到答案:alternative solutions
# 1 0x1b40d808 in __psynch_cvwait + 24 (libsystem_kernel.dylib + 0x00015808) 0x0
# 2 0x1b4c3cb3 in _pthread_cond_wait + 561 (libsystem_pthread.dylib + 0x00002cb3) 0x0
# 3 0x1b4c5033 in pthread_cond_wait + 37 (libsystem_pthread.dylib + 0x00004033) 0x190e50a0
# 4 0x1be0ed7 in SyncCondition::Wait() (SyncSynchronization.h:592) (MyApp + 0x01ba9ed7) 0x190e50ac
# 5 0x1be0f0b in SyncCondition::WaitForDuration(unsigned long) (MyAppSync.cpp:469) (MyApp + 0x01ba9f0b) 0x190e50b4
# 6 0x446ebef in invocation function for block in wlm_dispatch_create_block_wrapper(void () block_pointer) (MyAppThread_objc.mm:203) (MyApp + 0x04437bef) 0x190e5e78
# 7 0x1b30d795 in _dispatch_call_block_and_release + 9 (libdispatch.dylib + 0x00001795) 0x190e5f24
# 8 0x1b31ab1b in _dispatch_queue_override_invoke + 535 (libdispatch.dylib + 0x0000eb1b) 0x190e5f30
# 9 0x1b31c1b3 in _dispatch_root_queue_drain + 325 (libdispatch.dylib + 0x000101b3) 0x190e5f58
# 10 0x1b31c00d in _dispatch_worker_thread3 + 105 (libdispatch.dylib + 0x0001000d) 0x190e5f90
# 11 0x1b4c28eb in _pthread_wqthread + 1039 (libsystem_pthread.dylib + 0x000018eb) 0x190e5fa0
# 12 0x1b4c24ca in start_wqthread + 6 (libsystem_pthread.dylib + 0x000014ca) 0x190e5fe0
返回:
$sum = $connection->fetchAll("declare @dateFrom DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(DATEADD(m, -1, GETDATE() - 2)) ), DATEADD(m, -1, GETDATE() - 1)));
declare @dateTo DATETIME=CONVERT(DATE, DATEADD(d, -( DAY(GETDATE()) ), GETDATE()));
WITH DateTable
AS
(
SELECT CONVERT(date,@dateFrom) AS [DATE]
UNION ALL
SELECT CONVERT(date,DATEADD(dd, 1, [DATE]))
FROM DateTable
WHERE DATEADD(dd, 1, [DATE]) < @dateTo
)
SELECT dt.[DATE]
FROM [DateTable] dt;
");
$type = "is " . gettype($sum);
$count = count($sum);
return $response->build(200, [], [
'type'=>$type,
'count'=>$count,
'summary' => $sum,
]);