变更
This commit is contained in:
+27
-23
@@ -28,19 +28,19 @@ class Command extends Component
|
||||
const FETCH_ALL = 'fetchAll';
|
||||
const EXECUTE = 'execute';
|
||||
const FETCH_COLUMN = 'fetchColumn';
|
||||
|
||||
|
||||
const DB_ERROR_MESSAGE = 'The system is busy, please try again later.';
|
||||
|
||||
|
||||
/** @var Connection */
|
||||
public Connection $connection;
|
||||
|
||||
|
||||
/** @var ?string */
|
||||
public ?string $sql = '';
|
||||
|
||||
|
||||
/** @var array */
|
||||
public array $params = [];
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return int|bool
|
||||
* @throws Exception
|
||||
@@ -49,7 +49,7 @@ class Command extends Component
|
||||
{
|
||||
return $this->_execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int|bool
|
||||
* @throws Exception
|
||||
@@ -58,8 +58,8 @@ class Command extends Component
|
||||
{
|
||||
return $this->_execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return bool|array|null
|
||||
* @throws Exception
|
||||
@@ -82,7 +82,7 @@ class Command extends Component
|
||||
$this->connection->release($pdo ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool|array|null
|
||||
* @throws Exception
|
||||
@@ -105,7 +105,7 @@ class Command extends Component
|
||||
$this->connection->release($client ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool|array|null
|
||||
* @throws Exception
|
||||
@@ -128,7 +128,7 @@ class Command extends Component
|
||||
$this->connection->release($client ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int|bool
|
||||
* @throws Exception
|
||||
@@ -151,8 +151,8 @@ class Command extends Component
|
||||
$this->connection->release($client ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return int|bool
|
||||
* @throws Exception
|
||||
@@ -161,7 +161,7 @@ class Command extends Component
|
||||
{
|
||||
return $this->_execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool|int
|
||||
* @throws ConfigException
|
||||
@@ -179,6 +179,10 @@ class Command extends Component
|
||||
}
|
||||
$result = $client->lastInsertId();
|
||||
$prepare->closeCursor();
|
||||
|
||||
if (!$client->inTransaction()) {
|
||||
$this->connection->release($client);
|
||||
}
|
||||
return $result == 0 ? true : $result;
|
||||
} catch (\Throwable $throwable) {
|
||||
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
||||
@@ -187,8 +191,8 @@ class Command extends Component
|
||||
return $this->error($throwable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param \Throwable $throwable
|
||||
* @return bool
|
||||
@@ -198,8 +202,8 @@ class Command extends Component
|
||||
$message = $this->sql . '(' . json_encode($this->params, JSON_UNESCAPED_UNICODE) . ');';
|
||||
return $this->logger->addError($message . $throwable->getMessage(), 'mysql');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return int|bool
|
||||
* @throws Exception
|
||||
@@ -208,7 +212,7 @@ class Command extends Component
|
||||
{
|
||||
return $this->_execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int|bool
|
||||
* @throws Exception
|
||||
@@ -217,7 +221,7 @@ class Command extends Component
|
||||
{
|
||||
return $this->_execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return $this
|
||||
@@ -229,7 +233,7 @@ class Command extends Component
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $sql
|
||||
* @return $this
|
||||
@@ -240,5 +244,5 @@ class Command extends Component
|
||||
$this->sql = $sql;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user