改名
This commit is contained in:
@@ -13,6 +13,7 @@ use Snowflake\Abstracts\Component;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use PDO;
|
use PDO;
|
||||||
use PDOStatement;
|
use PDOStatement;
|
||||||
|
use Snowflake\Abstracts\Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Command
|
* Class Command
|
||||||
@@ -190,6 +191,7 @@ class Command extends Component
|
|||||||
private function execute($type, $isInsert = null, $hasAutoIncrement = true)
|
private function execute($type, $isInsert = null, $hasAutoIncrement = true)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$time = microtime(true);
|
||||||
if ($type === static::EXECUTE) {
|
if ($type === static::EXECUTE) {
|
||||||
$result = $this->insert_or_change($isInsert, $hasAutoIncrement);
|
$result = $this->insert_or_change($isInsert, $hasAutoIncrement);
|
||||||
} else {
|
} else {
|
||||||
@@ -198,6 +200,9 @@ class Command extends Component
|
|||||||
if ($this->prepare instanceof PDOStatement) {
|
if ($this->prepare instanceof PDOStatement) {
|
||||||
$this->prepare->closeCursor();
|
$this->prepare->closeCursor();
|
||||||
}
|
}
|
||||||
|
if (Config::get('debug.enable', false, false)) {
|
||||||
|
$this->debug($this->sql . '。 Run-time: ' . (microtime(true) - $time));
|
||||||
|
}
|
||||||
} catch (\Throwable | Exception $exception) {
|
} catch (\Throwable | Exception $exception) {
|
||||||
$this->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql');
|
$this->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql');
|
||||||
$result = null;
|
$result = null;
|
||||||
@@ -241,14 +246,14 @@ class Command extends Component
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (($result = $this->prepare->execute($this->params)) === false) {
|
if (($result = $this->prepare->execute($this->params)) === false) {
|
||||||
return $this->addError($connection->errorInfo()[2],'mysql');
|
return $this->addError($connection->errorInfo()[2], 'mysql');
|
||||||
}
|
}
|
||||||
if (!$isInsert) {
|
if (!$isInsert) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$result = $connection->lastInsertId();
|
$result = $connection->lastInsertId();
|
||||||
if ($result == 0 && $hasAutoIncrement) {
|
if ($result == 0 && $hasAutoIncrement) {
|
||||||
return $this->addError($connection->errorInfo()[2],'mysql');
|
return $this->addError($connection->errorInfo()[2], 'mysql');
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -268,7 +273,7 @@ class Command extends Component
|
|||||||
}
|
}
|
||||||
$this->prepare = $connect->prepare($this->sql);
|
$this->prepare = $connect->prepare($this->sql);
|
||||||
if (!($this->prepare instanceof PDOStatement)) {
|
if (!($this->prepare instanceof PDOStatement)) {
|
||||||
return $this->addError($this->sql . ':' . $this->getError(),'mysql');
|
return $this->addError($this->sql . ':' . $this->getError(), 'mysql');
|
||||||
}
|
}
|
||||||
return $connect;
|
return $connect;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use HttpServer\Http\Request as HRequest;
|
|||||||
use HttpServer\Http\Response as HResponse;
|
use HttpServer\Http\Response as HResponse;
|
||||||
use HttpServer\Route\Node;
|
use HttpServer\Route\Node;
|
||||||
use HttpServer\Service\Http;
|
use HttpServer\Service\Http;
|
||||||
|
use Snowflake\Abstracts\Config;
|
||||||
use Snowflake\Core\JSON;
|
use Snowflake\Core\JSON;
|
||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
@@ -35,8 +36,10 @@ class OnRequest extends Callback
|
|||||||
*/
|
*/
|
||||||
public function onHandler(Request $request, Response $response)
|
public function onHandler(Request $request, Response $response)
|
||||||
{
|
{
|
||||||
function_exists('trackerHookMalloc') && trackerHookMalloc();
|
|
||||||
try {
|
try {
|
||||||
|
if (Config::get('debug.enable', false, false)) {
|
||||||
|
function_exists('trackerHookMalloc') && trackerHookMalloc();
|
||||||
|
}
|
||||||
/** @var HRequest $sRequest */
|
/** @var HRequest $sRequest */
|
||||||
[$sRequest, $sResponse] = [HRequest::create($request), HResponse::create($response)];
|
[$sRequest, $sResponse] = [HRequest::create($request), HResponse::create($response)];
|
||||||
if ($sRequest->is('favicon.ico')) {
|
if ($sRequest->is('favicon.ico')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user