我尝试使用 Symfony 中的 Doctrine 将以下查询发送到 MSSQL 服务器:
DECLARE @ebayitems TABLE (kartikel INT, cartnr VARCHAR(255), ebayPrice DECIMAL(10,2), ebayID VARCHAR(255))
DECLARE @amazonitems TABLE (kartikel INT, cartnr VARCHAR(255), amazonPrice DECIMAL(10,2), amazonPriceVersand DECIMAL(10,2), amazonASIN VARCHAR(255))
DECLARE @shopitems TABLE (kartikel INT, cartnr VARCHAR(255), ebayPrice DECIMAL(10,2), latestEbayID VARCHAR(255), amazonPrice DECIMAL(10,2), latestAmazonASIN VARCHAR(255))
INSERT INTO @ebayitems
select tArt.kartikel, tArt.cartnr, ebay.ebay_price AS ebayPrice, ebay.ItemID AS ebayID
...
GROUP BY tArt.kartikel, tArt.cartnr, ebay.ebay_price, ebay.ItemID
INSERT INTO @amazonitems
select tArt.kartikel, tArt.cartnr, amazon.fprice, CASE WHEN amazon.fprice < 315 THEN amazon.fprice + 4.90 ELSE amazon.fprice + 5.90 end AS amazonPrice, amazon.casin1 AS AmazonASIN
...
GROUP BY tArt.kartikel, tArt.cartnr, amazon.fprice, amazon.casin1
INSERT INTO @shopitems
SELECT ebayitems.kartikel, ebayitems.cartnr, ebayPrice, MAX(ebayID) AS latestEbayID, amazonitems.amazonPriceVersand, max(amazonitems.amazonASIN) AS latestAmazonASIN
...
GROUP BY ebayitems.kartikel, ebayitems.cartnr, ebayPrice, amazonitems.amazonPriceVersand
SELECT items.cartnr,
tPreis.kpreis AS kpreis,
(CASE WHEN ebayPrice > amazonPrice THEN (FLOOR(MIN(amazonPrice) * 0.95)-0.10) / 1.19
ELSE (FLOOR(MIN(ebayPrice) * 0.95)-0.10) / 1.19 END) AS shoppreis,
ebayprice,
latestEbayID,
amazonprice,
latestAmazonASIN
...
GROUP BY items.cartnr, kpreis, ebayprice,
latestEbayID,
amazonprice,
latestAmazonASIN
我从标题中得到了错误。
如果我从 HeidiSQL 运行整个程序,它会完美运行 但是如果我尝试下面的代码它不会($conn 变量设置正确,连接正常)
$items = $conn->executeQuery($selectSQL);
var_dump($items->fetchAllAssociative());
有人知道我该怎么做吗?