|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Jiaoyin;
|
|
|
|
|
|
|
|
use Swoole\Database\MysqliConfig;
|
|
...
|
...
|
@@ -16,7 +17,7 @@ class MysqlCli |
|
|
|
private $connectConfig = null;
|
|
|
|
private $database = null;
|
|
|
|
|
|
|
|
public function __construct($host,$port,$database,$username,$password,$charset='utf8',$prefix='', $connectCount = 20)
|
|
|
|
public function __construct($host, $port, $database, $username, $password, $charset = 'utf8', $prefix = '', $connectCount = 20)
|
|
|
|
{
|
|
|
|
$this->database = $database;
|
|
|
|
$this->prefix = $prefix;
|
|
...
|
...
|
@@ -35,7 +36,7 @@ class MysqlCli |
|
|
|
|
|
|
|
private function poolConnect()
|
|
|
|
{
|
|
|
|
if($this->pool){
|
|
|
|
if ($this->pool) {
|
|
|
|
$this->pool->close();
|
|
|
|
}
|
|
|
|
$this->pool = new MysqliPool((new MysqliConfig)
|
|
...
|
...
|
@@ -45,7 +46,7 @@ class MysqlCli |
|
|
|
->withCharset($this->connectConfig['charset'])
|
|
|
|
->withUsername($this->connectConfig['username'])
|
|
|
|
->withPassword($this->connectConfig['password'])
|
|
|
|
,$this->connectConfig['connectCount']
|
|
|
|
, $this->connectConfig['connectCount']
|
|
|
|
);
|
|
|
|
$this->prefix = $this->connectConfig['prefix'];
|
|
|
|
}
|
|
...
|
...
|
@@ -116,7 +117,7 @@ class MysqlCli |
|
|
|
$data = $this->execute('SELECT', $sql);
|
|
|
|
$newData = [];
|
|
|
|
if (empty($col)) {
|
|
|
|
$newsql = 'SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = "'.$this->database.'" AND TABLE_NAME="' . $this->parseTable($table) . '" ORDER BY `ORDINAL_POSITION` ASC';
|
|
|
|
$newsql = 'SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = "' . $this->database . '" AND TABLE_NAME="' . $this->parseTable($table) . '" ORDER BY `ORDINAL_POSITION` ASC';
|
|
|
|
$coldata = $this->execute('SELECT', $newsql);
|
|
|
|
if (!$coldata) {
|
|
|
|
return false;
|
|
...
|
...
|
@@ -208,8 +209,12 @@ class MysqlCli |
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$value[1] = $this->transferValue($value[1]);
|
|
|
|
$symbol = isset($value[2]) ? $value[2] : '=';
|
|
|
|
if ($value[1] === 'NULL') {
|
|
|
|
$tmp = $value[0] . ' is NULL';
|
|
|
|
} else {
|
|
|
|
$symbol = $value[2] ?? '=';
|
|
|
|
$tmp .= $value[0] . ' ' . $symbol . ' ' . $value[1];
|
|
|
|
}
|
|
|
|
$tmp .= $key < count($where) - 1 ? ' and ' : '';
|
|
|
|
}
|
|
|
|
$whereTxt .= $tmp;
|
...
|
...
|
|