php - 什么是 Mysql 链接?

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

最佳答案

一个MySQL链接是resource的类型由 mysql_connect() 返回.

除了将它传递给其他 MySQL 函数外,您无能为力 - 它只是一个指向内部连接的“指针”(更像是一个索引)。

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

关于php - 什么是 Mysql 链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1130270/

相关文章:

c - 子 Makefile.am 中的标志

debugging - 将一对 int 列表转换为 OCaml 中的 boolean 矩阵

debugging - 如何在 ThinkOrSwim 平台中单步执行 thinkscript?

php - 无效查询,在 'INET_ATON (' IP 附近使用的语法')'

php - 引用 - 这个错误在 PHP 中意味着什么?

PHP $this 变量

mysql - 数据仓库任意字段

php - 分解数字并用空格分隔

php - 登录表单在实时服务器上第一次尝试失败,但在第二次或第三次尝试时有效

php - drupal中的日期时间插入问题