PHP中mysql_connect()函数的鲜为人知的重要特性
2010-09-25 16:20
585 查看
这两天郁闷的经历促使我编写了一段下面这个变态的脚本:
结果让我恍然大悟:Resource id #2Resource id #3Resource id #3
原来只有第一个mysql_connect函数建立了一个连接,在他关闭之前,如果参数相同再次调用这个函数的话,不会重新建立一个连接,而是重用这个连接。正如php.net对这个函数的定义一样:
Opens or reuses a connection to a MySQL server.
$a = mysql_connect("localhost","root","password"); mysql_close($a); $b = mysql_connect("localhost","root","password"); $c = mysql_connect("localhost","root","password"); echo $a."/n"; echo $b."/n"; echo $c."/n";
结果让我恍然大悟:Resource id #2Resource id #3Resource id #3
原来只有第一个mysql_connect函数建立了一个连接,在他关闭之前,如果参数相同再次调用这个函数的话,不会重新建立一个连接,而是重用这个连接。正如php.net对这个函数的定义一样:
Opens or reuses a connection to a MySQL server.
相关文章推荐
- PHP下使用mysqli的函数连接mysql出现warning: mysqli::real_connect(): (hy000/1040): ...
- mysql_connect() php7不支持,php5.5可以,是废弃函数
- [Php.ini]PHP调用mysql_connect()函数出错:Call to undefined function mysql_connect()
- PHP调用mysql_connect()函数报错:Call to undefined function mysql_connect()解决办法
- PHP下使用mysqli的函数连接mysql出现warning: mysqli::real_connect(): (hy000/1040): ...
- Mysql重要不常用的函数系列
- PHP里10个鲜为人知但却非常有用的函数
- PHP里10个鲜为人知但却非常有用的函数
- [乐意黎转载]PHP mysql_real_escape_string() 函数
- PHP操作mysql函数详解,mysql和php交互函数
- 解决Mysql报错:PHP Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication.
- php中mysql有关函数
- php服务器出现CodeIgniter错误mysql_connect(): No such file or directory解决方法
- php-redis函数帮助手册_consturct_connect_open_pconnect...
- PHP中一些重要的函数总结
- php cli mysql_real_escape_string() 函数Fatal error解决办法
- Fatal error: Call to undefined function mysql_connect() (PHP连MYSQL)
- 借助PHP的mysql_query()函数来创建MySQL数据库的教程
- php session_set_save_handler 函数的用法(mysql)
- php Mysql日期和时间函数集合