...
|
...
|
@@ -24,7 +24,7 @@ class bodySql { |
|
|
* @time 2023/3/23 10:15
|
|
|
*/
|
|
|
public static function first(int $id):string {
|
|
|
return "select * from `".static::$table."` where `lists_id` = {$id} limit 1";
|
|
|
return "select * from `".static::$table."` where `lists_id` = ".$id." limit 1";
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -35,7 +35,7 @@ class bodySql { |
|
|
* @time 2023/3/23 10:15
|
|
|
*/
|
|
|
public static function has(int $id){
|
|
|
return "select count(*) from `".static::$table."` where `lists_id` = {$id} limit 1";
|
|
|
return "select count(*) from `".static::$table."` where `lists_id` = ".$id." limit 1";
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -48,11 +48,13 @@ class bodySql { |
|
|
* @time 2023/4/10 17:30
|
|
|
*/
|
|
|
public static function insertOrUpdate(DbPool $db,$data){
|
|
|
try {
|
|
|
return $db->insert(bodySql::$table,$data,false);
|
|
|
}catch (\Throwable $e){
|
|
|
|
|
|
if($db->count(self::has($data['lists_id']))){
|
|
|
return $db->update(bodySql::$table,$data,dbWhere(['lists_id' => $data['lists_id']]),false);
|
|
|
}else{
|
|
|
return $db->insert(bodySql::$table,$data,false);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|