我对Magento很陌生,只是学习模型。我试图遵循艾伦风暴教程,并创建了我的模型。但是,以下代码会导致内存溢出错误:
Allowed memory size of 67108864 bytes exhausted (tried to allocate 65488 bytes) in C:'xampp'htdocs'magento'app'code'core'Mage'Core'Model'App.php on line 447
我的IndexController.php
看起来像这样:
<?php
class Lock_Weblog_IndexController extends Mage_Core_Controller_Front_Action {
public function testModelAction() {
$params = $this->getRequest()->getParams();
$blogpost = Mage::getModel('weblog/blogpost');
echo("Loading the blogpost with an ID of ".$params['id']);
$blogpost->load(1);
//$data = $blogpost->getData();
//var_dump($data);
}
}
?>
我的config.xml是这样的:
<config>
<global>
<modules>
<Lock_Weblog>
<version>1.0</version>
</Lock_Weblog>
</modules>
<models>
<weblog>
<class>Lock_Weblog_Model</class>
<resourceModel>weblog_mysql4</resourceModel>
</weblog>
<weblog_mysql4>
<class>Lock_Weblog_Model_Mysql4</class>
<entities>
<blogpost>
<table>blog_posts</table>
</blogpost>
</entities>
</weblog_mysql4>
</models>
<resources>
<weblog_write>
<connection>
<use>core_write</use>
</connection>
</weblog_write>
<weblog_read>
<connection>
<use>core_read</use>
</connection>
</weblog_read>
</resources>
</global>
<frontend>
<routers>
<weblog>
<use>standard</use>
<args>
<module>Lock_Weblog</module>
<frontName>weblog</frontName>
</args>
</weblog>
</routers>
</frontend>
</config>
我完全失去了做什么来解决这个问题!感谢您的帮助
Magento需要256M
(512M
最好)memory_limit
才能正常运行。
你只有64M
。在php.ini中增加限制,一切都会正常工作。