如题所述
PHP è¿æ¥æ°æ®åºæ两ç§æ¹å¼ï¼ mysql_connect() å mysql_pconnect() ãä¸é¢åå«ä»ç»ä½¿ç¨çä¸åä¹å¤ï¼
1ãmysql_pconnect() å½æ°æå¼ä¸ä¸ªå° MySQL æå¡å¨çæä¹ è¿æ¥ã
2ãmysql_pconnect() å mysql_connect() é常ç¸ä¼¼ï¼ä½æ两个主è¦åºå«ï¼
1.å½è¿æ¥çæ¶åæ¬å½æ°å°å
å°è¯å¯»æ¾ä¸ä¸ªå¨åä¸ä¸ªä¸»æºä¸ç¨åæ ·çç¨æ·ååå¯ç å·²ç»æå¼çï¼æä¹
ï¼è¿æ¥ï¼å¦ææ¾å°ï¼åè¿åæ¤è¿æ¥æ è¯èä¸æå¼æ°è¿æ¥ã
2.å
¶æ¬¡ï¼å½èæ¬æ§è¡å®æ¯åå° SQL æå¡å¨çè¿æ¥ä¸ä¼è¢«å
³éï¼æ¤è¿æ¥å°ä¿ææå¼ä»¥å¤ä»¥å使ç¨ï¼mysql_close() ä¸ä¼å
³éç± mysql_pconnect() 建ç«çè¿æ¥ï¼ã
è¯æ³
mysql_pconnect(server,user,pwd,clientflag)åæ° æè¿°
server å¯éãè§å®è¦è¿æ¥çæå¡å¨ã
å¯ä»¥å æ¬ç«¯å£å·ï¼ä¾å¦ "hostname:port"ï¼æè å°æ¬å°å¥æ¥åçè·¯å¾ï¼ä¾å¦å¯¹äº localhost ç ":/path/to/socket"ã
å¦æ PHP æ令 mysql.default_host æªå®ä¹ï¼é»è®¤æ
åµï¼ï¼åé»è®¤å¼æ¯ 'localhost:3306'ã
user å¯éãç¨æ·åãé»è®¤å¼æ¯æå¡å¨è¿ç¨ææè
çç¨æ·åã
pwd å¯éãå¯ç ãé»è®¤å¼æ¯ç©ºå¯ç ã
clientflag å¯éãclient_flags åæ°å¯ä»¥æ¯ä»¥ä¸å¸¸éçç»åï¼
•MYSQL_CLIENT_SSL - ä½¿ç¨ SSL å å¯
•MYSQL_CLIENT_COMPRESS - 使ç¨å缩åè®®
•MYSQL_CLIENT_IGNORE_SPACE - å
许å½æ°ååçé´é
•MYSQL_CLIENT_INTERACTIVE - å
许å
³éè¿æ¥ä¹åç交äºè¶
æ¶éæ´»å¨æ¶é´
è¿åå¼
å¦ææåï¼åè¿åä¸ä¸ª MySQL æä¹
è¿æ¥æ è¯ç¬¦ï¼åºéåè¿å FALSEã
æ示å注é
注éï¼å¯éåæ° clientflag èª PHP 4.3.0 çèµ·å¯ç¨ã
æ示ï¼è¦å建ä¸ä¸ªéæä¹
è¿æ¥ï¼è¯·ä½¿ç¨ mysql_connect() å½æ°ã
ä¾åå¦ä¸ï¼
主è¦ä½¿ç¨åºåï¼
å½dbæ纵éæï¼ èæ¶è¾é¿æ¶ï¼ å httpdä¼forkå¾å¤å¹¶åè¿ç¨å¤çæ©ç½ï¼ èå 产ççhttpdè¿ç¨ä¸å¼édbè¿æ¥ï¼ 使å¾å产ççhttpdè¿ç¨æ æ³è¿ä¸db. å 为å¦è®¸æ²¡æå¤ç¨å ¶å®httpdè¿ç¨çmysqlè¿æ¥. äºæ¯ä¼å°±äº§çå¾å¤è¿æ¥è¶ æ¶ã å¨å¹¶åæ¥è§éä¸é«æ¶ï¼åºç¨pconnectå¯ä»¥ç®åè¿æ¥æ¥è§éåº¦ï¼ ä½å¨å¹¶åéå¢å¤§åï¼ æ¯å¦ååºç¨pconnectå°±è¦è§å°åº¦åçéæ©äº.