php mysql 资源,PHP mysql_connect资源始终相同

I'm having a problem my php script witch you can see here:

http://codepad.org/F0qhElRC

Is not opening a new resource for each connection from a child.

Already I tryed using 127.0.0.1 or my local network IP but nothing worked,

also max_user_connections in mysql is set to 0 opening a connection from web gives me a different

resource for the web. But in the command line it uses the same.

In mysql_connect I specified new_link to be true, I placed a __destruct in the bd class

to close the connection if the child get's destroyed. Closing the connection does not make

php open a new one even after I restart the script. The resource could be free and so I should

count on that but in the childs I also have tryed placing a sleep but that doesn't make it run

a new resource.

Any sugestions on how to debug this?

Basically I whant a new conn for every new script or child call.

Thanks in advance.

Best regards,

解决方案

You've managed to omit all the relevant code, but many database extensions in PHP reuse currently open connections unless you specifically instruct them not to do so. If you are using mysql_connect(), have a look at the $new_link parameter:

mysql_connect — Open a connection to a MySQL Server

Report a bug

Description

resource mysql_connect ([ string $server = ini_get("mysql.default_host") [, string $username = ini_get("mysql.default_user") [, string $password = ini_get("mysql.default_password") [, bool $new_link = false [, int $client_flags = 0 ]]]]] )

Opens or reuses a connection to a MySQL server.

.

new_link

If a second call is made to mysql_connect() with the same

arguments, no new link will be

established, but instead, the link

identifier of the already opened link

will be returned. The new_link

parameter modifies this behavior and

makes mysql_connect() always open a

new link, even if mysql_connect() was

called before with the same

parameters. In SQL safe mode, this

parameter is ignored.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值