★ wanayoo — archive 1999 http://www.php.net/manual/ja/function.mysql-pconnect.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to MySQL
Quick Reference
English version of this pageGerman version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
MySQL
* mysql_affected_rows
* mysql_change_user
* mysql_close
* mysql_connect
* mysql_create_db
* mysql_data_seek
* mysql_db_query
* mysql_drop_db
* mysql_errno
* mysql_error
* mysql_fetch_array
* mysql_fetch_field
* mysql_fetch_lengths
* mysql_fetch_object
* mysql_fetch_row
* mysql_field_name
* mysql_field_seek
* mysql_field_table
* mysql_field_type
* mysql_field_flags
* mysql_field_len
* mysql_free_result
* mysql_insert_id
* mysql_list_fields
* mysql_list_dbs
* mysql_list_tables
* mysql_num_fields
* mysql_num_rows
* mysql_pconnect
* mysql_query
* mysql_result
* mysql_select_db
* mysql_tablename
Manual: mysql_pconnect
View the source code for this pageSearch the site



Previous page
 mysql_num_rows
 Updated
Mon, 14 Aug 2000
mysql_query 
Next page


mysql_pconnect

(PHP3 , PHP4 )

mysql_pconnect --  MySQLサーバーへの持続的な接続をオープンする

説明

int mysql_pconnect ([string hostname [:port] [:/path/to/socket] [, string username [, string password]]])

成功した場合に正のMySQL持続的link_identifier、エラー発生時にfalseを 返します。

mysql_pconnect()は、MySQLサーバーへの 接続を確立します。全ての引数はオプションであり、 省略された場合には、デフォルト値('localhost'、サーバープロセスの 所有者のユーザ名、空のパスワード)が仮定されます。

文字列hostnameには、"hostname:port"のようにポート番号を 指定することが可能で、localhostでは、":/path/to/socket" のようにソケットへのパスを指定することも可能です。

注意: ":port"のサポートは、3.0B4で追加されました。

":/path/to/socket"のサポートは3.0.10で追加されました。

mysql_pconnect()は、二つの点を除いて mysql_connect()と全く同様に動作します。

1番目の違いとしては、この関数は、接続時にまず 同じホスト、ユーザ名、パスワードを有する(持続的)リンクが すでにオープンされていないかどうかを調べます。 それがみつかった場合、新規の接続をオープンする代わりに そのリンクのIDが返されます。

2番目の違いは、SQLサーバーへの接続がスクリプトの実行終了時にも 閉じられないということです。 代わりに、リンクは将来的な使用のためにオープンされたままと なります。(mysql_close()は、 mysql_pconnect()により確立されたリンクを 閉じません)

このため、この型のリンクは、'持続的(persistent)'であると言われます。


User Contributed Notes: mysql_pconnect


norman@dontblink.com
10-Nov-1999 01:06
If you are getting this error message:
"Fatal error: Call to unsupported or undefined function mysql_pconnect()" with PHP on win98 it may be because you do not have support for MySQL compiled into your php binary. I suspect you'll need to get a compiler and install from source.



bolke@xs4all.nl
25-Nov-1999 04:05
If you get that error on a unix system, probably you have used a binary distribution (such as a RPM). Get the tarball and install it from scratch.


bdial@rkkengineers.com
07-Jan-2000 05:49
Here's a short example. say you had a small mysql table with Name and Phone fields in a table called phonenums in a database called info.

$my_pconn = mysql_pconnect("localhost", "root", "sex");
$my_results = mysql_db_query("info", "select * from phonenums", $my_pconn);
while($phoneinfo = mysql_fetch_array($my_results)) {
echo "$phoneinfo[Name] 's phone number is $phoneinfo[Phone]
";
}

or say you passed a cgi var of $new_num into a php3 script to update someones number

$update_attempt = mysql_db_query("info", "update phonenum set Phone = '$new_num' where Name = 'Bob'", $my_pconn);

Hope this helps



jhihn1@hotmail.com
21-Mar-2000 03:04
For win32 users - the 'Fatal error - call to unsupported function' for connect and pconnect is because you didn't uncomment out the mysql dll in the php.ini file, under Windows Extensions:

--------------------------

;Windows Extensions
extension=php3_mysql.dll



aschmidt@targetnet.com
31-Mar-2000 09:20
Re: Persistant connections.
You are calling mysql_pconnect on each page load right?
If not, I believe that mysql_pconnect will cause php to close the socket after the page has finished loading. (unless another client has that socket open). I could be wrong, but the main purpose of pconnect is so there are as few active connections open to mysql at the same time as possible.

and on a side note: You can't keep a mysql connection in a cookie.



louis@trapezoid.com
12-Apr-2000 04:35
If you get an error stating that you don't have support for MySQL functions, then you need the MySQL library (.dll for winblows, .so for UNIX/Linux). I think the DLL comes with the windows distro. As for linux, the easiest way is to get an RPM of php-3.X-mysql-i386.rpm. This has the mysql.so file in it, and is precompiled for Intel-Linux. You will need to relocate (--relocate) the file paths in the RPM command, otherwise, it'll check the dependancies and say you don't have the right version. Anyway, once you've gotten the mysql.so file out of the RPM, just copy it to the PHP shared-files directory (might be the same as Apache, but you can check in the php.ini/php.cfg file). Alternatively, you can search for a DSO file (.so) that you know you have and put the mysql.so with it.


kyledrake@usinternet.com
14-Apr-2000 09:15
If you are using apache & php and are having
undefined function problems, you might be getting
it because you are restarting apache and not turning it off & turning it back on. you MUST stop apache to apply the new changes, a restart doesn't cut it.



sasha@mysql.com
27-Apr-2000 09:43
If you need to close idle persistent connections, set a low wait_timeout in MySQL


 About Notes


Previous page
 mysql_num_rows
 Updated
Mon, 14 Aug 2000
mysql_query 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.