Link to home
Create AccountLog in
Avatar of umaxim
umaximFlag for United States of America

asked on

PHP

Hi i have a system which parse XML file with news. It gets it of article in database and then if it not there it add to database. But the problem is to many connection because it check every 15 minutes and it have 30 queries to database. So i thinking to make some cache for it maybe save last answer from XML and compare to new one and if it now the same then it begin checking. Or i thinking create some TXT file with all id of articles and then compare it to it. What else you can recommend what can help me ?
ASKER CERTIFIED SOLUTION
Avatar of Bardobrave
Bardobrave
Flag of Spain image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of umaxim

ASKER

Yes i do not close them after how i can close i just new in regular programming. I every time use codeigniter it close connection by it self. What you can recomend m.
I don't know about CodeIgniter, it's some type of framework for PHP, I think.

Suposedly it should have some type of gargabe collection that closes any open connection when finishing to execute code, but I don't know if actually it has.

Keep in mind that your database will have a limit to the number of concurrent connections it can manage, also, more open connections means more resources.

You should try to use the minimum number of connections on your code, usually you create them on the fly when accessing database and close/destroy them when database operations are finished.

If you keep your database connections open, on the long run you'll find that your database runs slowly and, eventually, it blocks any further operation due to a too many open connections error.

The way you close your database connections on php could vary depending on the database.

This site has a full reference on PHP:
http://www.php.net/
Avatar of umaxim

ASKER

Thank you for help i found what was the error. I used persistent connection in my script and server every time show error too many connection. Thank you for help.