内核更新
This commit is contained in:
@@ -226,13 +226,17 @@ abstract class Connection
|
||||
/**
|
||||
* 设置数据库的配置参数
|
||||
* @access public
|
||||
* @param string $config 配置名称
|
||||
* @param mixed $value 配置值
|
||||
* @param string|array $config 配置名称
|
||||
* @param mixed $value 配置值
|
||||
* @return void
|
||||
*/
|
||||
public function setConfig($config, $value)
|
||||
public function setConfig($config, $value = '')
|
||||
{
|
||||
$this->config[$config] = $value;
|
||||
if (is_array($config)) {
|
||||
$this->config = array_merge($this->config, $config);
|
||||
} else {
|
||||
$this->config[$config] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +251,7 @@ abstract class Connection
|
||||
public function connect(array $config = [], $linkNum = 0, $autoConnection = false)
|
||||
{
|
||||
if (!isset($this->links[$linkNum])) {
|
||||
if (empty($config)) {
|
||||
if (!$config) {
|
||||
$config = $this->config;
|
||||
}
|
||||
// 连接参数
|
||||
@@ -281,20 +285,6 @@ abstract class Connection
|
||||
return $this->links[$linkNum];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前数据库的驱动类型
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDriverName()
|
||||
{
|
||||
if ($this->linkID) {
|
||||
return $this->linkID->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||
} else {
|
||||
return $this->config['type'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放查询结果
|
||||
* @access public
|
||||
|
||||
@@ -59,7 +59,7 @@ class Query
|
||||
public function __construct(Connection $connection = null, $model = '')
|
||||
{
|
||||
$this->connection = $connection ?: Db::connect([], true);
|
||||
$this->driver = $this->connection->getDriverName();
|
||||
$this->driver = $this->connection->getConfig('type');
|
||||
$this->prefix = $this->connection->getConfig('prefix');
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,12 @@ class Sqlsrv extends Connection
|
||||
];
|
||||
}
|
||||
}
|
||||
$sql = "SELECT column_name FROM information_schema.key_column_usage WHERE table_name='$tableName'";
|
||||
$pdo = $this->linkID->query($sql);
|
||||
$result = $pdo->fetch(PDO::FETCH_ASSOC);
|
||||
if ($result) {
|
||||
$info[$result['column_name']]['primary'] = true;
|
||||
}
|
||||
return $this->fieldCase($info);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user