我正在调试一个 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/