#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Posts
    37
    Rep Power
    26
    I'm totally confused about when and how to use mysql_pconnect() vs mysql_connect().

    I'm creating a sql wrapper function:

    function sql_wrapper ($sSql) {

      $iConn = mysql_connect();
      $iResult = mysql_db_query ("db", $sSql, $iConn);

      ...
      ...

    }

    Which function should I use?
    Should $iConn be a static variable?

    If I want to use mysql_insert_id(), do I have to use mysql_connect to keep the threads separate?

    Help!
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    riddler,

    Major difference between the mysql_pconnect() and mysql_connect() is that mysql_pconnect will open a persistent connection to a MySQL Server.but in the case of mysql_connect() it opens a simple connection to a MySQL Server.

    see the difference here in the following links:
    http://www2.phpbuilder.com/manual/fu...-pconnect.php3
    http://www2.phpbuilder.com/manual/fu...l-connect.php3

    You can use eigther of this function as per your project requirment.




    ------------------
    SR -
    shiju.dreamcenter.net
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Posts
    37
    Rep Power
    26
    Hi SR,

    I've read all of the documentation about the functions and I understand what they do. What I'm confused about are the practical effects of each.

    When is it desirable to use a persistent connection? When is it perilous to do so?

    Does mysql_pconnect() mean that the entire application will only use one connection to the database throughout the *entire* lifetime of the app?

    Will it always use a single thread?

    If I want to capture the last insert ID, do I have to use mysql_connect() instead?

IMN logo majestic logo threadwatch logo seochat tools logo