{"id":32,"date":"2008-06-02T02:26:00","date_gmt":"2008-06-02T06:26:00","guid":{"rendered":"http:\/\/www.searchenginegenie.com\/programming-blog\/mysql_connect-vs-mysql_pconnect\/"},"modified":"2012-09-21T06:17:58","modified_gmt":"2012-09-21T10:17:58","slug":"mysql_connect-vs-mysql_pconnect","status":"publish","type":"post","link":"https:\/\/www.searchenginegenie.com\/programming-blog\/mysql_connect-vs-mysql_pconnect\/","title":{"rendered":"Mysql_connect Vs Mysql_pconnect"},"content":{"rendered":"<p>There are two different connections available, if you are connecting to a MySQL database in your PHP application, mysql_connect &#8211; which set up a new connection &#8220;each time&#8221; and mysql_pconnect which uses persistent connections.<\/p>\n<p>Mysql_connect opens a new connection each time a PHP page is called, and closes the connection down again at the end of the request. It is perfect for pages that do not have a heavy usage.<\/p>\n<p>Mysql_pconnect will also open a new connection when a PHP page is called, but it will NOT close the connection at the end of the request &#8211; instead, it will put aside it in a connection pool so that a succeeding request can persist to use the same connection. It&#8217;s intended for pages that have a heavy usage &#8211; where the resources burn up by opening and closing connections every time might reduce performance.<\/p>\n<p>But mysql_pconnect need some tuning of the servers and you may require limiting the numbers of connections \/ children and configuring timeouts and how to deal with idle children.<\/p>\n<p>By using this you have some drawbacks as follows.<br \/>\nIt does NOT give you sessions.<br \/>\nIt does NOT give you a per-site-visitor login.<br \/>\nIt does NOT give you any added functionality.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two different connections available, if you are connecting to a MySQL database in your PHP application, mysql_connect &#8211; which set up a new connection &#8220;each time&#8221; and mysql_pconnect which uses persistent connections. Mysql_connect opens a new connection each time a PHP page is called, and closes the connection down again at the end [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[93,94],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-php","tag-mysql-connect","tag-mysql-pconnect"],"_links":{"self":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":3,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":406,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/posts\/32\/revisions\/406"}],"wp:attachment":[{"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/programming-blog\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}