改名
This commit is contained in:
@@ -199,7 +199,7 @@ class Command extends Component
|
|||||||
$this->prepare->closeCursor();
|
$this->prepare->closeCursor();
|
||||||
}
|
}
|
||||||
} catch (\Throwable | Exception $exception) {
|
} catch (\Throwable | Exception $exception) {
|
||||||
$this->error($this->sql . '. error: ' . $exception->getMessage());
|
$this->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql');
|
||||||
$result = null;
|
$result = null;
|
||||||
} finally {
|
} finally {
|
||||||
return $result;
|
return $result;
|
||||||
@@ -241,20 +241,19 @@ 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]);
|
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]);
|
return $this->addError($connection->errorInfo()[2],'mysql');
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重新构建
|
* 重新构建
|
||||||
* @throws
|
* @throws
|
||||||
@@ -269,7 +268,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());
|
return $this->addError($this->sql . ':' . $this->getError(),'mysql');
|
||||||
}
|
}
|
||||||
return $connect;
|
return $connect;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace HttpServer\Exception;
|
||||||
|
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ExitException
|
||||||
|
* @package HttpServer\Exception
|
||||||
|
*/
|
||||||
|
class ExitException extends \Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ExitException constructor.
|
||||||
|
* @param string $message
|
||||||
|
* @param int $code
|
||||||
|
* @param Throwable|null $previous
|
||||||
|
*/
|
||||||
|
public function __construct($message = "", $code = 0, Throwable $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace HttpServer\Route;
|
|||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use HttpServer\Exception\ExitException;
|
||||||
use HttpServer\Http\Context;
|
use HttpServer\Http\Context;
|
||||||
use HttpServer\Http\Request;
|
use HttpServer\Http\Request;
|
||||||
use HttpServer\IInterface\RouterInterface;
|
use HttpServer\IInterface\RouterInterface;
|
||||||
@@ -405,7 +406,6 @@ class Router extends Application implements RouterInterface
|
|||||||
|
|
||||||
$newPath[] = strtoupper($item->method) . ' : ' . $route . '/' . $item->path;
|
$newPath[] = strtoupper($item->method) . ' : ' . $route . '/' . $item->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return $newPath;
|
return $newPath;
|
||||||
}
|
}
|
||||||
@@ -424,6 +424,8 @@ class Router extends Application implements RouterInterface
|
|||||||
} else {
|
} else {
|
||||||
$response = send($node->dispatch(), 200);
|
$response = send($node->dispatch(), 200);
|
||||||
}
|
}
|
||||||
|
} catch (ExitException $exception) {
|
||||||
|
$response = send(Snowflake::app()->getLogger()->exception($exception), 200);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$response = send(Snowflake::app()->getLogger()->exception($exception), 200);
|
$response = send(Snowflake::app()->getLogger()->exception($exception), 200);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user