什么是Mysql Link?

Ibn*_*eed 1 php mysql debugging

我正在调试一个php应用程序.

在"本地调试"窗口中,它显示以下信息

  • 名称值类型
  • LinkID 15 mysql链接

LinkID的值在程序中发生变化

什么是mysql链接类型,在调试窗口中显示?

此外,任何人都可以解释该功能的作用吗?

这是使用LinkID的php代码:

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;
    }
Run Code Online (Sandbox Code Playgroud)

Gre*_*reg 5

MySQL链接是返回的资源类型mysql_connect().

除了将它传递给其他MySQL函数之外,你无法用它做什么 - 它只是一个内部连接的"指针"(更像是一个索引).

15对没有任何意义- 它在PHP内部使用,它使用它来跟踪真正的 mysql连接对象(没有理由传递给你的PHP脚本).