SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast doubli's Avatar
    Join Date
    Sep 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Effective interaction with a my-sql database

    I'm in the process of planning a new site structure. I want to make sure that I am interacting with my-sql db in the most effective way. At present, I have an include file at the top of every page that requires access to database data

    eg

    include ("global/include_logon_user.php");

    This file contains something along the lines of

    $connect = @mysql_connect("localhost","user","pas");
    @mysql_select_db("database") or die ("Could not connect to database")

    I've also set about adding mysql_close($connect) recently to the end of my pages, in an effort to make sure database connections are closed down. I know it does close down automatically but I Wanted to be sure

    So, am I going about things in the correct way? Is there anything negative in the way I'm hitting the database and opening a connection with every page request? Can I do things smarter?
    One of lifes luxuries ...

  2. #2
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are going to be in constant contact with your database, look into persistant connections.

    mysql_pconnect() is a good place to start.
    John

  3. #3
    SitePoint Enthusiast doubli's Avatar
    Join Date
    Sep 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PHP John
    If you are going to be in constant contact with your database, look into persistant connections.

    mysql_pconnect() is a good place to start. [img]images/smilies/smile.gif[/img]
    Thanks John, I've done some reading on mysql_pconnect and there does seem to be some negative comments in using it on the php.net site.

    What do others use here?
    One of lifes luxuries ...


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
  •