What is Mysql Link?

advertisements

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;
    }


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).