I have my own php data object class that wraps the mysqli library. It works fine handling most datatypes, including text. As soon as I change a table column from text to mediumtext, I get the error described in the title of this question. I've tested my php scripts on several shared hosting environments, and I only get this error on one of them.
我有自己的php数据对象类,它包装了mysqli库。它可以很好地处理大多数数据类型,包括文本。只要我将表格列从text更改为mediumtext,我就会收到此问题标题中描述的错误。我在几个共享托管环境中测试了我的PHP脚本,我只在其中一个上面得到了这个错误。
Does the MediumText and LongText really use up that much memory?
MediumText和LongText真的耗尽了那么多内存吗?
I will start optimizing my php classes, but I want to make sure I'm on the right track..
我将开始优化我的php课程,但我想确保我在正确的轨道上..
3 个解决方案
#1
mediumtext can hold up to 16777215 as specified in http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html
mediumtext最多可以容纳16777215,如http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html中所述。
This would appear to be > than you memory limit as defined by php. So it makes sense.
这看起来比你定义的内存限制大得多。所以这很有道理。
#2
The mediumtext and longtext fields could, potentially, hold that much information. Are you just changing the column type, or are you changing the column type then jamming it full of text? If it's the former, my guess would be that there's some run away loop/recursion that's building up a bunch of objects/arrays/somethings and you're hitting PHP's default memory ceiling.
中间文本和长文本字段可能会保留那么多信息。您只是更改列类型,还是更改列类型然后将其填满文本?如果它是前者,我的猜测是,有一些逃跑循环/递归正在构建一堆对象/数组/某些东西,而你正在达到PHP的默认内存上限。
You can control the amount of memory allocated to PHP via php.ini, or you can use the ini_set function to set the values at run-time.
您可以通过php.ini控制分配给PHP的内存量,也可以使用ini_set函数在运行时设置值。
ini_set("memory_limit","12M");
#3
That hosting provider probably has PHP set to only allow a script 8 megabytes of memory.
该托管服务提供商可能将PHP设置为仅允许脚本8兆字节的内存。
memory_limit = 8M ; Maximum amount of memory a script may consume
memory_limit = 8M;脚本可能消耗的最大内存量
You can check what this is set to using phpinfo(), create a script with the following, upload it and point your web browser at it (make sure you remove it once done as it gives away potentially sensitive information):
您可以使用phpinfo()检查设置的内容,使用以下内容创建脚本,上传并将Web浏览器指向它(确保在完成后将其删除,因为它会泄露潜在的敏感信息):
<?php
phpinfo()
?>
Look for "memory_limit" towards the bottom. If it's set to 8 megabytes that's your problem.
在底部寻找“memory_limit”。如果它设置为8兆字节那就是你的问题。
#1
mediumtext can hold up to 16777215 as specified in http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html
mediumtext最多可以容纳16777215,如http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html中所述。
This would appear to be > than you memory limit as defined by php. So it makes sense.
这看起来比你定义的内存限制大得多。所以这很有道理。
#2
The mediumtext and longtext fields could, potentially, hold that much information. Are you just changing the column type, or are you changing the column type then jamming it full of text? If it's the former, my guess would be that there's some run away loop/recursion that's building up a bunch of objects/arrays/somethings and you're hitting PHP's default memory ceiling.
中间文本和长文本字段可能会保留那么多信息。您只是更改列类型,还是更改列类型然后将其填满文本?如果它是前者,我的猜测是,有一些逃跑循环/递归正在构建一堆对象/数组/某些东西,而你正在达到PHP的默认内存上限。
You can control the amount of memory allocated to PHP via php.ini, or you can use the ini_set function to set the values at run-time.
您可以通过php.ini控制分配给PHP的内存量,也可以使用ini_set函数在运行时设置值。
ini_set("memory_limit","12M");
#3
That hosting provider probably has PHP set to only allow a script 8 megabytes of memory.
该托管服务提供商可能将PHP设置为仅允许脚本8兆字节的内存。
memory_limit = 8M ; Maximum amount of memory a script may consume
memory_limit = 8M;脚本可能消耗的最大内存量
You can check what this is set to using phpinfo(), create a script with the following, upload it and point your web browser at it (make sure you remove it once done as it gives away potentially sensitive information):
您可以使用phpinfo()检查设置的内容,使用以下内容创建脚本,上传并将Web浏览器指向它(确保在完成后将其删除,因为它会泄露潜在的敏感信息):
<?php
phpinfo()
?>
Look for "memory_limit" towards the bottom. If it's set to 8 megabytes that's your problem.
在底部寻找“memory_limit”。如果它设置为8兆字节那就是你的问题。