mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
改进Cache类 及 驱动 改进Connection类及驱动
This commit is contained in:
@@ -21,7 +21,7 @@ use think\exception\DbBindParamException;
|
||||
use think\exception\PDOException;
|
||||
use think\Log;
|
||||
|
||||
abstract class Connection implements ConnectionInterface
|
||||
abstract class Connection
|
||||
{
|
||||
// PDO操作实例
|
||||
protected $PDOStatement;
|
||||
@@ -124,6 +124,38 @@ abstract class Connection implements ConnectionInterface
|
||||
return call_user_func_array([$this->query, $method], $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析pdo连接的dsn信息
|
||||
* @access protected
|
||||
* @param array $config 连接信息
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function parseDsn($config);
|
||||
|
||||
/**
|
||||
* 取得数据表的字段信息
|
||||
* @access public
|
||||
* @param string $tableName
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getFields($tableName);
|
||||
|
||||
/**
|
||||
* 取得数据库的表信息
|
||||
* @access public
|
||||
* @param string $dbName
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getTables($dbName);
|
||||
|
||||
/**
|
||||
* SQL性能分析
|
||||
* @access protected
|
||||
* @param string $sql
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function getExplain($sql);
|
||||
|
||||
/**
|
||||
* 对返数据表字段信息进行大小写转换出来
|
||||
* @access public
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\db;
|
||||
|
||||
interface ConnectionInterface
|
||||
{
|
||||
/**
|
||||
* 解析pdo连接的dsn信息
|
||||
* @access public
|
||||
* @param array $config 连接信息
|
||||
* @return string
|
||||
*/
|
||||
public function parseDsn($config);
|
||||
|
||||
/**
|
||||
* 取得数据表的字段信息
|
||||
* @access public
|
||||
* @param string $tableName
|
||||
* @return array
|
||||
*/
|
||||
public function getFields($tableName);
|
||||
|
||||
/**
|
||||
* 取得数据库的表信息
|
||||
* @access public
|
||||
* @param string $dbName
|
||||
* @return array
|
||||
*/
|
||||
public function getTables($dbName);
|
||||
|
||||
/**
|
||||
* SQL性能分析
|
||||
* @access protected
|
||||
* @param string $sql
|
||||
* @return array
|
||||
*/
|
||||
public function getExplain($sql);
|
||||
}
|
||||
@@ -22,11 +22,11 @@ class Mysql extends Connection
|
||||
|
||||
/**
|
||||
* 解析pdo连接的dsn信息
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param array $config 连接信息
|
||||
* @return string
|
||||
*/
|
||||
public function parseDsn($config)
|
||||
protected function parseDsn($config)
|
||||
{
|
||||
$dsn = 'mysql:dbname=' . $config['database'] . ';host=' . $config['hostname'];
|
||||
if (!empty($config['hostport'])) {
|
||||
@@ -91,11 +91,11 @@ class Mysql extends Connection
|
||||
|
||||
/**
|
||||
* SQL性能分析
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param string $sql
|
||||
* @return array
|
||||
*/
|
||||
public function getExplain($sql)
|
||||
protected function getExplain($sql)
|
||||
{
|
||||
$pdo = $this->linkID->query("EXPLAIN " . $sql);
|
||||
$result = $pdo->fetch(\PDO::FETCH_ASSOC);
|
||||
|
||||
@@ -24,11 +24,11 @@ class Oracle extends Connection
|
||||
|
||||
/**
|
||||
* 解析pdo连接的dsn信息
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param array $config 连接信息
|
||||
* @return string
|
||||
*/
|
||||
public function parseDsn($config)
|
||||
protected function parseDsn($config)
|
||||
{
|
||||
$dsn = 'oci:dbname=';
|
||||
if (!empty($config['hostname'])) {
|
||||
@@ -139,11 +139,11 @@ class Oracle extends Connection
|
||||
|
||||
/**
|
||||
* SQL性能分析
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param string $sql
|
||||
* @return array
|
||||
*/
|
||||
public function getExplain($sql)
|
||||
protected function getExplain($sql)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ class Pgsql extends Connection
|
||||
|
||||
/**
|
||||
* 解析pdo连接的dsn信息
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param array $config 连接信息
|
||||
* @return string
|
||||
*/
|
||||
public function parseDsn($config)
|
||||
protected function parseDsn($config)
|
||||
{
|
||||
$dsn = 'pgsql:dbname=' . $config['database'] . ';host=' . $config['hostname'];
|
||||
if (!empty($config['hostport'])) {
|
||||
@@ -79,11 +79,11 @@ class Pgsql extends Connection
|
||||
|
||||
/**
|
||||
* SQL性能分析
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param string $sql
|
||||
* @return array
|
||||
*/
|
||||
public function getExplain($sql)
|
||||
protected function getExplain($sql)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ class Sqlite extends Connection
|
||||
|
||||
/**
|
||||
* 解析pdo连接的dsn信息
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param array $config 连接信息
|
||||
* @return string
|
||||
*/
|
||||
public function parseDsn($config)
|
||||
protected function parseDsn($config)
|
||||
{
|
||||
$dsn = 'sqlite:' . $config['database'];
|
||||
return $dsn;
|
||||
@@ -78,11 +78,11 @@ class Sqlite extends Connection
|
||||
|
||||
/**
|
||||
* SQL性能分析
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param string $sql
|
||||
* @return array
|
||||
*/
|
||||
public function getExplain($sql)
|
||||
protected function getExplain($sql)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ class Sqlsrv extends Connection
|
||||
|
||||
/**
|
||||
* 解析pdo连接的dsn信息
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param array $config 连接信息
|
||||
* @return string
|
||||
*/
|
||||
public function parseDsn($config)
|
||||
protected function parseDsn($config)
|
||||
{
|
||||
$dsn = 'sqlsrv:Database=' . $config['database'] . ';Server=' . $config['hostname'];
|
||||
if (!empty($config['hostport'])) {
|
||||
@@ -96,11 +96,11 @@ class Sqlsrv extends Connection
|
||||
|
||||
/**
|
||||
* SQL性能分析
|
||||
* @access public
|
||||
* @access protected
|
||||
* @param string $sql
|
||||
* @return array
|
||||
*/
|
||||
public function getExplain($sql)
|
||||
protected function getExplain($sql)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user