简体   繁体   中英

PHP+MYSQL Server Config

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.

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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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