mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
改进断线重连判断
This commit is contained in:
@@ -51,7 +51,6 @@ class Mysql extends Connection
|
|||||||
*/
|
*/
|
||||||
public function getFields($tableName)
|
public function getFields($tableName)
|
||||||
{
|
{
|
||||||
$this->initConnect(false);
|
|
||||||
list($tableName) = explode(' ', $tableName);
|
list($tableName) = explode(' ', $tableName);
|
||||||
if (false === strpos($tableName, '`')) {
|
if (false === strpos($tableName, '`')) {
|
||||||
if (strpos($tableName, '.')) {
|
if (strpos($tableName, '.')) {
|
||||||
@@ -59,12 +58,8 @@ class Mysql extends Connection
|
|||||||
}
|
}
|
||||||
$tableName = '`' . $tableName . '`';
|
$tableName = '`' . $tableName . '`';
|
||||||
}
|
}
|
||||||
$sql = 'SHOW COLUMNS FROM ' . $tableName;
|
$sql = 'SHOW COLUMNS FROM ' . $tableName;
|
||||||
// 调试开始
|
$pdo = $this->query($sql, [], false, true);
|
||||||
$this->debug(true);
|
|
||||||
$pdo = $this->linkID->query($sql);
|
|
||||||
// 调试结束
|
|
||||||
$this->debug(false, $sql);
|
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$info = [];
|
$info = [];
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -91,13 +86,8 @@ class Mysql extends Connection
|
|||||||
*/
|
*/
|
||||||
public function getTables($dbName = '')
|
public function getTables($dbName = '')
|
||||||
{
|
{
|
||||||
$this->initConnect(false);
|
$sql = !empty($dbName) ? 'SHOW TABLES FROM ' . $dbName : 'SHOW TABLES ';
|
||||||
$sql = !empty($dbName) ? 'SHOW TABLES FROM ' . $dbName : 'SHOW TABLES ';
|
$pdo = $this->query($sql, [], false, true);
|
||||||
// 调试开始
|
|
||||||
$this->debug(true);
|
|
||||||
$pdo = $this->linkID->query($sql);
|
|
||||||
// 调试结束
|
|
||||||
$this->debug(false, $sql);
|
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$info = [];
|
$info = [];
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
|
|||||||
@@ -44,14 +44,11 @@ class Pgsql extends Connection
|
|||||||
*/
|
*/
|
||||||
public function getFields($tableName)
|
public function getFields($tableName)
|
||||||
{
|
{
|
||||||
$this->initConnect(false);
|
|
||||||
list($tableName) = explode(' ', $tableName);
|
list($tableName) = explode(' ', $tableName);
|
||||||
$sql = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg(\'' . $tableName . '\');';
|
$sql = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg(\'' . $tableName . '\');';
|
||||||
// 调试开始
|
|
||||||
$this->debug(true);
|
$pdo = $this->query($sql, [], false, true);
|
||||||
$pdo = $this->linkID->query($sql);
|
|
||||||
// 调试结束
|
|
||||||
$this->debug(false, $sql);
|
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$info = [];
|
$info = [];
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -78,13 +75,8 @@ class Pgsql extends Connection
|
|||||||
*/
|
*/
|
||||||
public function getTables($dbName = '')
|
public function getTables($dbName = '')
|
||||||
{
|
{
|
||||||
$this->initConnect(false);
|
$sql = "select tablename as Tables_in_test from pg_tables where schemaname ='public'";
|
||||||
$sql = "select tablename as Tables_in_test from pg_tables where schemaname ='public'";
|
$pdo = $this->query($sql, [], false, true);
|
||||||
// 调试开始
|
|
||||||
$this->debug(true);
|
|
||||||
$pdo = $this->linkID->query($sql);
|
|
||||||
// 调试结束
|
|
||||||
$this->debug(false, $sql);
|
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$info = [];
|
$info = [];
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
|
|||||||
@@ -42,14 +42,10 @@ class Sqlite extends Connection
|
|||||||
*/
|
*/
|
||||||
public function getFields($tableName)
|
public function getFields($tableName)
|
||||||
{
|
{
|
||||||
$this->initConnect(false);
|
|
||||||
list($tableName) = explode(' ', $tableName);
|
list($tableName) = explode(' ', $tableName);
|
||||||
$sql = 'PRAGMA table_info( ' . $tableName . ' )';
|
$sql = 'PRAGMA table_info( ' . $tableName . ' )';
|
||||||
// 调试开始
|
|
||||||
$this->debug(true);
|
$pdo = $this->query($sql, [], false, true);
|
||||||
$pdo = $this->linkID->query($sql);
|
|
||||||
// 调试结束
|
|
||||||
$this->debug(false, $sql);
|
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$info = [];
|
$info = [];
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -76,15 +72,12 @@ class Sqlite extends Connection
|
|||||||
*/
|
*/
|
||||||
public function getTables($dbName = '')
|
public function getTables($dbName = '')
|
||||||
{
|
{
|
||||||
$this->initConnect(false);
|
|
||||||
$sql = "SELECT name FROM sqlite_master WHERE type='table' "
|
$sql = "SELECT name FROM sqlite_master WHERE type='table' "
|
||||||
. "UNION ALL SELECT name FROM sqlite_temp_master "
|
. "UNION ALL SELECT name FROM sqlite_temp_master "
|
||||||
. "WHERE type='table' ORDER BY name";
|
. "WHERE type='table' ORDER BY name";
|
||||||
// 调试开始
|
|
||||||
$this->debug(true);
|
$pdo = $this->query($sql, [], false, true);
|
||||||
$pdo = $this->linkID->query($sql);
|
|
||||||
// 调试结束
|
|
||||||
$this->debug(false, $sql);
|
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$info = [];
|
$info = [];
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ class Sqlsrv extends Connection
|
|||||||
*/
|
*/
|
||||||
public function getFields($tableName)
|
public function getFields($tableName)
|
||||||
{
|
{
|
||||||
$this->initConnect(false);
|
|
||||||
list($tableName) = explode(' ', $tableName);
|
list($tableName) = explode(' ', $tableName);
|
||||||
$sql = "SELECT column_name, data_type, column_default, is_nullable
|
$sql = "SELECT column_name, data_type, column_default, is_nullable
|
||||||
FROM information_schema.tables AS t
|
FROM information_schema.tables AS t
|
||||||
@@ -58,11 +57,8 @@ class Sqlsrv extends Connection
|
|||||||
AND t.table_schema = c.table_schema
|
AND t.table_schema = c.table_schema
|
||||||
AND t.table_name = c.table_name
|
AND t.table_name = c.table_name
|
||||||
WHERE t.table_name = '$tableName'";
|
WHERE t.table_name = '$tableName'";
|
||||||
// 调试开始
|
|
||||||
$this->debug(true);
|
$pdo = $this->query($sql, [], false, true);
|
||||||
$pdo = $this->linkID->query($sql);
|
|
||||||
// 调试结束
|
|
||||||
$this->debug(false, $sql);
|
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$info = [];
|
$info = [];
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -99,16 +95,12 @@ class Sqlsrv extends Connection
|
|||||||
*/
|
*/
|
||||||
public function getTables($dbName = '')
|
public function getTables($dbName = '')
|
||||||
{
|
{
|
||||||
$this->initConnect(false);
|
|
||||||
$sql = "SELECT TABLE_NAME
|
$sql = "SELECT TABLE_NAME
|
||||||
FROM INFORMATION_SCHEMA.TABLES
|
FROM INFORMATION_SCHEMA.TABLES
|
||||||
WHERE TABLE_TYPE = 'BASE TABLE'
|
WHERE TABLE_TYPE = 'BASE TABLE'
|
||||||
";
|
";
|
||||||
// 调试开始
|
|
||||||
$this->debug(true);
|
$pdo = $this->query($sql, [], false, true);
|
||||||
$pdo = $this->linkID->query($sql);
|
|
||||||
// 调试结束
|
|
||||||
$this->debug(false, $sql);
|
|
||||||
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$info = [];
|
$info = [];
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
|
|||||||
Reference in New Issue
Block a user