Jump to content

A few MYSQL questions


Anidazen

Recommended Posts

Hey guys.


I'm trying to battle with an incredibly persistant problem in one of my scripts - regarding SQL interaction.

Basically, I connect at the beginning of the script, do two queries, then the script runs... and this can take quite a while - under 10 seconds would be counted as very fortunate. Then after it's run I save the results. However, I'm getting errors occasionally on this last query ("server has gone away", "lost connection to server").

I've added a mysql_ping(); line just before this query, and when it fails it returns false to this.



Basically, I can direct solving this into 3 questions:

1) I thought mysql_ping() auto reconnected. Do I need to add a connect line for when it returns false? What about select database?
2) I'm using mysql_pconnect() at the start of the script - would I be better off using a different variation of the function, maybe closing it then reconnecting?
3) Any general advice I might not of thought of?
Link to comment
https://forums.phpfreaks.com/topic/35939-a-few-mysql-questions/
Share on other sites

@wildteen88-
Correct me if I a wrong, but as far as I know a persistent connection cannot be closed.
From the manual:
[i]"the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect())."[/i]
It seems like it's closed automatically somehow....

EDIT- after some reading, it appears that persistent connection just don't close.
@Anidazen- Try increasing the mysql.connect_timeout directive and see if the connection still times-out.

Orio.
Link to comment
https://forums.phpfreaks.com/topic/35939-a-few-mysql-questions/#findComment-170551
Share on other sites

[quote author=Orio link=topic=124276.msg514800#msg514800 date=1169916450]
@wildteen88-
Correct me if I a wrong, but as far as I know a persistent connection cannot be closed.
From the manual:
[i]"the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect())."[/i]
It seems like it's closed automatically somehow....

EDIT- after some reading, it appears that persistent connection just don't close.
@Anidazen- Try increasing the mysql.connect_timeout directive and see if the connection still times-out.

Orio.
[/quote]
mmm... I swear you could use mysql_close to close a persistent connection before. I guess they have changed that now.
Link to comment
https://forums.phpfreaks.com/topic/35939-a-few-mysql-questions/#findComment-170568
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.