...
|
...
|
@@ -99,12 +99,7 @@ class DbPool { |
|
|
|
|
|
$sql = "update `{$table}` set ".dbUpdate($data). " where ".$where;
|
|
|
|
|
|
// 如果存储的值是数组,就json一次
|
|
|
foreach ($data as $k=>$datum){
|
|
|
if(is_array($datum)){
|
|
|
$data[$k] = json_encode($datum,JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
}
|
|
|
$data = $this->getData($data);
|
|
|
|
|
|
$query = $this->query([$sql,$data]);
|
|
|
if($query){
|
...
|
...
|
@@ -115,6 +110,26 @@ class DbPool { |
|
|
|
|
|
|
|
|
/**
|
|
|
* 在更新/插入时处理数据
|
|
|
* @param $data
|
|
|
* @return mixed
|
|
|
* @author:dc
|
|
|
* @time 2023/2/18 14:50
|
|
|
*/
|
|
|
private function getData($data){
|
|
|
// 如果存储的值是数组,就json一次
|
|
|
foreach ($data as $k=>$datum){
|
|
|
if(is_array($datum)){
|
|
|
$data[$k] = json_encode($datum,JSON_UNESCAPED_UNICODE);
|
|
|
}elseif ($datum === null){
|
|
|
$data[$k] = '';
|
|
|
}
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 插入数据
|
|
|
* @param string $table
|
|
|
* @param array $data
|
...
|
...
|
@@ -131,12 +146,7 @@ class DbPool { |
|
|
|
|
|
$sql = "insert into `{$table}` set ".dbUpdate($data);
|
|
|
|
|
|
// 如果存储的值是数组,就json一次
|
|
|
foreach ($data as $k=>$datum){
|
|
|
if(is_array($datum)){
|
|
|
$data[$k] = json_encode($datum,JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
}
|
|
|
$data = $this->getData($data);
|
|
|
|
|
|
$query = $this->query([$sql,$data]);
|
|
|
|
...
|
...
|
|