Results 1 to 6 of 6

Thread: What are the Persistent Database Connections in PHP?

  1. #1
    Join Date
    May 2009
    Posts
    511

    What are the Persistent Database Connections in PHP?

    Hello everyone,
    I have done some basic things in PHP programming language and now I am moving towards the advanced part. I want to use SQL links and I think that I have gathered enough information about it. But before doing that I want to know about the connections of the persistent database. Since I am new to this topic, I don't have good knowledge about it. So please help me, by telling what are the Persistent Database Connections in PHP? Detailed
    explanation would be really appreciable.!!

  2. #2
    Join Date
    Mar 2008
    Posts
    672

    Re: What are the Persistent Database Connections in PHP?

    If you are not thoroughly familiar with web servers and distribute the workload is sometimes a false idea of the connections persistent. Persistent connections to databases are SQL links that do not close when the script ends. When a persistent connection is requested, PHP checks if there's not another similar connection (that remained open from earlier with the same host name, user and same password), and if such a connection exists, it is used, otherwise it is created. A similar connection is a connection that opened the same host, with the same name and same password (if necessary).

  3. #3
    Join Date
    Nov 2005
    Posts
    1,323

    Re: What are the Persistent Database Connections in PHP?

    In particular, persistent connections do not allow the opening of several sessions with the same link, they do not allow the efficient execution of transactions and do not like coffee. In fact, to be extremely clear on the subject, persistent connections do not give you any functionality that non-persistent. The persistent connections reflects the way that web servers operate. Persistent connections are a good way to accelerate access to a SQL database when processing database connection is long. This time depends on many factors: the type of database, the database is present on the same server or not, what is the server load database, etc.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: What are the Persistent Database Connections in PHP?

    There are three ways to use PHP to generate pages :
    1. The first is to use PHP as a CGI (Common Gateway Interface). When PHP works this way, an instance of the PHP interpreter is created and destroyed for every page requested. Because it is destroyed after every request, any resources acquired, are simply destroyed.
    2. The second method, by far the most popular, is to run PHP as a module in a multiprocess web server, which is to say, Apache. A server typically has a parent process which coordinates a set of processes son, serving files. When a request comes from a client, they are transmitted to a son available. Persistent connections then you can not connect to a SQL database as the first time.
    3. The last method is to use PHP as a module multithreaded server. Currently PHP 4 has support for ISAPI, WSAPI, and NSAPI (on Windows), which all allow PHP to be used as a module on multithreaded servers like Netscape FastTrack (iPlanet).

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: What are the Persistent Database Connections in PHP?

    You should keep in mind that persistent connections have some drawbacks if you host a database where the maximum number of connection may be achieved by persistent connections. If your database supports up to 22 simultaneous connections, and 23 processes trying to connect, the latter will remain on the sidelines. If there are errors in the scripts that do not close the connection (eg an infinite loop), your server will be rapidly swamped. The persistent connections were defined to have the same functionality as the non-persistent. Both types of connections are perfectly interchangeable, and will not affect the behavior of your script: only its effectiveness.

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: What are the Persistent Database Connections in PHP?

    There are some other warnings that you will have to keep in mind when using persistent connections. One is that when using table locking on a persistent connection, if the script can not release the lock for some reason, then subsequent scripts using the same connection will block indefinitely and may require that you restart the server or database. Another is that when using transactions, block trading will be extended to closed following script, if not closed by the script execution. In both cases, you can use the register_shutdown_function () to register a simple cleanup function to unlock your tables or roll back transactions. Better yet, avoid the problem entirely by not using persistent connections in scripts which use table locks or transactions. You can still use them elsewhere.

Similar Threads

  1. Backtrack 5 - USB Persistent Changes not working
    By Haleema in forum Operating Systems
    Replies: 6
    Last Post: 23-06-2011, 10:33 PM
  2. What does persistent wifi mean
    By Isiah in forum Networking & Security
    Replies: 6
    Last Post: 20-05-2010, 10:11 AM
  3. With DSN vs DSN Less Database Connections
    By Adrina_g in forum Software Development
    Replies: 5
    Last Post: 15-02-2010, 09:14 PM
  4. How to remote connections by MySQL database server
    By Arumugan in forum Software Development
    Replies: 4
    Last Post: 13-02-2010, 01:50 AM
  5. persistent cookies
    By Vibhas in forum Technology & Internet
    Replies: 2
    Last Post: 31-12-2008, 09:09 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,752,108,070.93779 seconds with 16 queries