...
|
...
|
@@ -172,6 +172,24 @@ trait DbQuery { |
|
|
*/
|
|
|
public function insert(string $table, array $data, $timeauto = true):int {
|
|
|
|
|
|
if($this->create($table, $data, $timeauto)){
|
|
|
return $this->getClient()->lastInsertId();
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 插入数据
|
|
|
* @param string $table
|
|
|
* @param array $data
|
|
|
* @param bool $timeauto
|
|
|
* @return int
|
|
|
* @author:dc
|
|
|
* @time 2023/2/17 14:04
|
|
|
*/
|
|
|
public function create(string $table, array $data, $timeauto = true):int {
|
|
|
|
|
|
if($timeauto){
|
|
|
$data['created_at'] = empty($data['created_at']) ? date('Y-m-d H:i:s') : $data['created_at'];
|
|
|
}
|
...
|
...
|
@@ -183,10 +201,10 @@ trait DbQuery { |
|
|
$query = $this->query([$sql,$data]);
|
|
|
|
|
|
if($query){
|
|
|
return $this->getClient()->lastInsertId();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|