简体   繁体   English

PHP + MYSQL服务器配置

[英]PHP+MYSQL Server Config

I am parsing an XML file with PHP and inserting the rows in a MYSQL database. 我正在用PHP解析XML文件,并将行插入MYSQL数据库中。

I am using PHP simplexml_load_files to load the XML and a foreach to loop through the array and insert the rows into my database. 我正在使用PHP simplexml_load_files加载XML,并使用foreach遍历数组并将行插入到数据库中。

It works perfectly fine with small files i am testing, but it comes to reality I need to parse a large 500mb XML file and nothing happens. 我正在测试的小文件可以很好地工作,但实际上我需要解析一个500mb的XML文件,什么也没有发生。

I was wondering what was the right Php.ini config for this case ? 我想知道这种情况下正确的Php.ini配置是什么?

I have a VPS Linux Cent OS, with 256 mb of dedicated Memory and MYSQL 5.0.5. 我有一个VPS Linux Cent操作系统,具有256 mb的专用内存和MYSQL 5.0.5。 I have also set php memory_limit = 256M (maximum of my server) 我还设置了php memory_limit = 256M(服务器的最大值)

gosh, a 500 MB XML file? 天哪,一个500 MB的XML文件? I guess you run out of memory. 我想您的内存不足了。 try XMLReader , that's a pull parser (parsing the XML (more or less) linewise), so that you don't run out of memory so easily. 尝试使用XMLReader ,它是拉式解析器(按行解析XML(或多或少)),这样您就不会那么容易用尽内存。

我建议您使用xmlreader ...就内存而言,它更有效

The memory config used for xml is located in a third party library, not at php.ini config. 用于xml的内存配置位于第三方库中,而不位于php.ini配置中。 Besides that you should XMLReader or ext/xml to process such a large file, that means streaming access and not use dom data access (SimpleXML). 除此之外,您还应该使用XMLReader或ext / xml来处理如此大的文件,这意味着流式访问而不是使用dom数据访问(SimpleXML)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM