eee
This commit is contained in:
@@ -117,6 +117,7 @@ class Command extends Component
|
|||||||
{
|
{
|
||||||
$client = $this->connection->getConnection();
|
$client = $this->connection->getConnection();
|
||||||
try {
|
try {
|
||||||
|
$this->connection->println($this->sql, $this->params);
|
||||||
if (($prepare = $client->prepare($this->sql)) === false) {
|
if (($prepare = $client->prepare($this->sql)) === false) {
|
||||||
throw new Exception('(' . $prepare->errorInfo()[0] . ')' . $client->errorInfo()[2]);
|
throw new Exception('(' . $prepare->errorInfo()[0] . ')' . $client->errorInfo()[2]);
|
||||||
}
|
}
|
||||||
@@ -157,6 +158,7 @@ class Command extends Component
|
|||||||
{
|
{
|
||||||
$client = $this->connection->getConnection();
|
$client = $this->connection->getConnection();
|
||||||
try {
|
try {
|
||||||
|
$this->connection->println($this->sql, $this->params);
|
||||||
if (($prepare = $client->prepare($this->sql)) === false) {
|
if (($prepare = $client->prepare($this->sql)) === false) {
|
||||||
throw new Exception('(' . $prepare->errorInfo()[0] . ')' . $prepare->errorInfo()[2]);
|
throw new Exception('(' . $prepare->errorInfo()[0] . ')' . $prepare->errorInfo()[2]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class Connection extends Component
|
|||||||
public bool $enableCache = false;
|
public bool $enableCache = false;
|
||||||
public string $cacheDriver = 'redis';
|
public string $cacheDriver = 'redis';
|
||||||
public array $attributes = [];
|
public array $attributes = [];
|
||||||
|
protected \Closure $_println;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,6 +70,21 @@ class Connection extends Component
|
|||||||
public function __construct(public Pool $connections)
|
public function __construct(public Pool $connections)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->_println = \config('databases.logger', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sql
|
||||||
|
* @param array $params
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function println(string $sql, array $params = []): void
|
||||||
|
{
|
||||||
|
if (is_callable($this->_println)) {
|
||||||
|
call_user_func($this->_println, $sql, $params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user