开发者

Can MySQL link (mysql_connect) be stored in Memcache and reused?

In PHP, can I do this?

$mysql = mysql_connect(...);
Memcache::set('mysql_connection', $mysql);

and then in another scrip开发者_高级运维t

$mysql = Memcache::get('mysql_connection');
mysql_query("some query", $mysql);

?


No, but you can use a pool of permanent connections with mysql_pconnect().


No, it can't. $mysql is actually just a memory pointer to the real MySQL link. The MySQL link is destroyed at the end of the script whether you want it or not, and you are left with a pointer to an undefined place in memory.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜