which one is the best way in connecting-disconnecting to mysql database ?

Discussion in 'MySQL' started by rajnikant, Feb 13, 2007.

  1. #1
    In my application, I opened a non-persistent mysql db connection at the top of the php file and I have closed it at the end of php file. so all db query functions (for ex. query(), getall(), fetchonerow() etc..) will use the same resouce id and perform the tasks.

    The other way I came to know is, establish a connection in all db functions first then perform the tasks and the close the opened connection at the end of all db functions.

    Which one is more efficient and the best way ?
     
    rajnikant, Feb 13, 2007 IP
  2. hamidof

    hamidof Peon

    Messages:
    619
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    One shared connection.
     
    hamidof, Feb 15, 2007 IP
  3. toby

    toby Notable Member

    Messages:
    6,923
    Likes Received:
    269
    Best Answers:
    0
    Trophy Points:
    285
    #3
    i prefer the open and close within the page itself as users may only request a connection per page basis.
     
    toby, Feb 15, 2007 IP