作者 邓超

x

@@ -110,8 +110,7 @@ class AutoMail { @@ -110,8 +110,7 @@ class AutoMail {
110 } 110 }
111 if(stripos($haystack,$str)!==false){ 111 if(stripos($haystack,$str)!==false){
112 if(!$this->db->count("select count(*) from `lists_auto` where `list_id` = ".$item['id'])){ 112 if(!$this->db->count("select count(*) from `lists_auto` where `list_id` = ".$item['id'])){
113 - $this->db->insert('`lists_auto`',['list_id'=>$item['id']],false);  
114 - echo "插入数据 ".$item['id']."\n"; 113 + echo "插入数据 ".$item['id'].'==>'.$this->db->create('lists_auto',['list_id'=>$item['id']],false).'==>'.$haystack."\n";
115 } 114 }
116 } 115 }
117 } 116 }
@@ -172,6 +172,24 @@ trait DbQuery { @@ -172,6 +172,24 @@ trait DbQuery {
172 */ 172 */
173 public function insert(string $table, array $data, $timeauto = true):int { 173 public function insert(string $table, array $data, $timeauto = true):int {
174 174
  175 + if($this->create($table, $data, $timeauto)){
  176 + return $this->getClient()->lastInsertId();
  177 + }
  178 +
  179 + return 0;
  180 + }
  181 +
  182 + /**
  183 + * 插入数据
  184 + * @param string $table
  185 + * @param array $data
  186 + * @param bool $timeauto
  187 + * @return int
  188 + * @author:dc
  189 + * @time 2023/2/17 14:04
  190 + */
  191 + public function create(string $table, array $data, $timeauto = true):int {
  192 +
175 if($timeauto){ 193 if($timeauto){
176 $data['created_at'] = empty($data['created_at']) ? date('Y-m-d H:i:s') : $data['created_at']; 194 $data['created_at'] = empty($data['created_at']) ? date('Y-m-d H:i:s') : $data['created_at'];
177 } 195 }
@@ -183,10 +201,10 @@ trait DbQuery { @@ -183,10 +201,10 @@ trait DbQuery {
183 $query = $this->query([$sql,$data]); 201 $query = $this->query([$sql,$data]);
184 202
185 if($query){ 203 if($query){
186 - return $this->getClient()->lastInsertId(); 204 + return true;
187 } 205 }
188 206
189 - return 0; 207 + return false;
190 } 208 }
191 209
192 /** 210 /**