开发者

PHP+MYSQL Server Config

开发者 https://www.devze.com 2022-12-29 10:00 出处:网络
I am parsing an XML file with PHP and inserting the rows in a MYSQL database. 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 d

I am parsing an XML file with PHP and inserting the rows in a MYSQL database.

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.

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.

I was wondering what was the right Php.ini config for this case ?

I 开发者_运维百科have a VPS Linux Cent OS, with 256 mb of dedicated Memory and MYSQL 5.0.5. I have also set php memory_limit = 256M (maximum of my server)


gosh, a 500 MB XML file? 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.


I suggest you use xmlreader ... its more efective as memory is concerned


The memory config used for xml is located in a third party library, not at php.ini config. 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消