views:

80

answers:

3

Hello

I am debugging a php application.

In the Local Debugging window, it shows the following information

  • Name value Type
  • LinkID 15 mysql link

The value of LinkID change within the program

What is mysql link type , being shown in the debugging window?

Also, can anyone explain what the function performs ?

Here is the php code using LinkID:

function connect($new_link = false) 
    {
     if (!$this->LinkID) {
      $server = ($this->DBPort != "") ? $this->DBHost . ":" . $this->DBPort : $this->DBHost;

      if ($this->DBPersistent) {
       $this->LinkID = @mysql_pconnect($server, $this->DBUser, $this->DBPassword);
      } else {
       $this->LinkID = @mysql_connect($server, $this->DBUser, $this->DBPassword, $new_link);
      }

      if (!$this->LinkID) {  
       $this->halt("Connect failed: " . $this->describe_error(mysql_errno(), mysql_error()));
       return 0;
      }

      if (!mysql_select_db($this->DBDatabase, $this->LinkID)) {
       $this->LinkID = 0;
       $this->halt($this->describe_error(mysql_errno(), mysql_error()));
       return 0;
      }
     }

     return $this->LinkID;
    }
+1  A: 

Your function creates different connections types to a database depending on your settings.

Henrik P. Hessel
+1  A: 

A "mysql link" is the name of a PHP Resource which is created by the mysql_connect or mysql_pconnect command.

Lachlan McDonald
+5  A: 

A MySQL link is the type of resource returned by mysql_connect().

There's not much you can do with it except pass it around to other MySQL functions - it's just a "pointer" (more like an index) to an internal connection.

The 15 doesn't mean anything to you - it's used internally in PHP, which uses it to keep track of the real mysql connection object (which has no reason to be passed to your PHP script).

Greg
What does the value 15 mysql link mean ?Sometimes the value is 11, 13 , 14 etc.
Ibn Saeed
The above function in my application uses the value of LinkID, in this case, 15.
Ibn Saeed
It's only useful for PHP internally to know which database connection to use (if it has more than one open at any one time), you have no influence on the value and the value has no influence on your app.
deceze
It does not "mean" anything. It is like a number so that you can know which mysql connection is used by your application. There is no inherit problem with changing value from request to request. Take this as an analogy: it doesn't matter if you sit left or right at the bar, the barkeeper still treats you the same, just keep sitting on your barstool.
Residuum
@Residuum,thanks for explanation.
Ibn Saeed