...
|
...
|
@@ -16,12 +16,28 @@ trait DbQuery { |
|
|
*/
|
|
|
protected $client;
|
|
|
|
|
|
/**
|
|
|
* 是否抛出异常
|
|
|
* @var bool
|
|
|
*/
|
|
|
protected $isThrow = false;
|
|
|
|
|
|
|
|
|
public function getClient()
|
|
|
{
|
|
|
return $this->client;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @return $this
|
|
|
* @author:dc
|
|
|
* @time 2024/7/24 9:09
|
|
|
*/
|
|
|
public function throw(){
|
|
|
$this->isThrow = true;
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询
|
...
|
...
|
@@ -46,6 +62,9 @@ trait DbQuery { |
|
|
$query = $this->getClient()->prepare($sql);
|
|
|
$ret = $query->execute($params);
|
|
|
}catch (\Throwable $e){
|
|
|
if($this->isThrow){
|
|
|
throw new DbException($e->getMessage(),$sql,$params,$e);
|
|
|
}
|
|
|
logs([
|
|
|
$sql,$params,
|
|
|
$e->getMessage(),
|
...
|
...
|
|