作者:plumscape_191 | 来源:互联网 | 2023-10-13 08:45
IhavetheweirdestPHPPDOproblem,andIhopeyouguyscansortitoutforme.我有最奇怪的PHPPDO问题,我希望
I have the weirdest PHP PDO problem, and I hope you guys can sort it out for me.
我有最奇怪的PHP PDO问题,我希望你们能为我解决这个问题。
If I set $checkLimit
to 50000, the query works fine. However, if I set it to anything above 50k, it doesn't return any results - and it doesn't cast any error messages either (I've already turned them on using $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING)
.
如果我将$ checkLimit设置为50000,则查询工作正常。但是,如果我将它设置为高于50k的任何值,它不会返回任何结果 - 它也不会抛出任何错误消息(我已经使用$ db-> setAttribute打开它们(PDO :: ATTR_ERRMODE,PDO) :: ERRMODE_WARNING)。
$sql = "
SELECT d_domain_name AS domainName, d_domain_id AS domainID
FROM domains
ORDER BY d_domain_name_length ASC, d_domain_name ASC
LIMIT :checkLimit
";
$stmt = $db->prepare($sql);
$stmt->bindValue(':checkLimit', intval($checkLimit), PDO::PARAM_INT);
$stmt->execute();
$results = $stmt->fetchAll();
foreach ($results as $result) {
// 50k moments of magic
}
If I run the query outside of PHP, it works with any limit (even 500k, takes about 3 minutes).
如果我在PHP之外运行查询,它可以使用任何限制(甚至500k,大约需要3分钟)。
I've tried changing $results = $stmt->fetchAll()
to while ($result = $stmt->fetch()) {}
in order to try and save memory, but that didn't do anything, unfortunately.
我尝试将$ results = $ stmt-> fetchAll()更改为while($ result = $ stmt-> fetch()){}以尝试保存内存,但不幸的是,这没有做任何事情。
Can anyone tell me what I'm doing wrong here? What am I missing? Why can't I go over 50k?
谁能告诉我这里我做错了什么?我错过了什么?为什么我不能超过50k?
1 个解决方案