|
@@ -41,7 +41,11 @@ class listsSql { |
|
@@ -41,7 +41,11 @@ class listsSql { |
|
41
|
* @time 2023/3/17 16:24
|
41
|
* @time 2023/3/17 16:24
|
|
42
|
*/
|
42
|
*/
|
|
43
|
public static function first($db,string $where,$filed='*', $throw=false) {
|
43
|
public static function first($db,string $where,$filed='*', $throw=false) {
|
|
44
|
-
|
44
|
+ if(is_array($where)){
|
|
|
|
45
|
+ $where = dbWhere($where);
|
|
|
|
46
|
+ }elseif (is_numeric($where)) {
|
|
|
|
47
|
+ $where = dbWhere(['id' => $where]);
|
|
|
|
48
|
+ }
|
|
45
|
foreach ([self::$table,"lists_back","lists_hot"] as $table) {
|
49
|
foreach ([self::$table,"lists_back","lists_hot"] as $table) {
|
|
46
|
$sql = "select {$filed} from `".$table."` where ".$where.' limit 1';
|
50
|
$sql = "select {$filed} from `".$table."` where ".$where.' limit 1';
|
|
47
|
if($throw){
|
51
|
if($throw){
|
|
@@ -58,7 +62,31 @@ class listsSql { |
|
@@ -58,7 +62,31 @@ class listsSql { |
|
58
|
}
|
62
|
}
|
|
59
|
|
63
|
|
|
60
|
|
64
|
|
|
|
|
65
|
+
|
|
|
|
66
|
+
|
|
|
|
67
|
+ public static function maxUid($db,string $where){
|
|
|
|
68
|
+ if(is_array($where)){
|
|
|
|
69
|
+ $where = dbWhere($where);
|
|
|
|
70
|
+ }elseif (is_numeric($where)) {
|
|
|
|
71
|
+ $where = dbWhere(['id' => $where]);
|
|
|
|
72
|
+ }
|
|
|
|
73
|
+ $uid = 0;
|
|
|
|
74
|
+ foreach ([self::$table,"lists_back",/*"lists_hot"*/] as $table) {
|
|
|
|
75
|
+ $sql = "select max(`uid`) as `mc` from `".$table."` where ".$where;
|
|
|
|
76
|
+ $data = $db->value($sql);
|
|
|
|
77
|
+ if($data) {
|
|
|
|
78
|
+ $uid = max($uid, $data);
|
|
|
|
79
|
+ }
|
|
|
|
80
|
+ }
|
|
|
|
81
|
+ return $uid;
|
|
|
|
82
|
+ }
|
|
|
|
83
|
+
|
|
61
|
public static function count($db,string $where){
|
84
|
public static function count($db,string $where){
|
|
|
|
85
|
+ if(is_array($where)){
|
|
|
|
86
|
+ $where = dbWhere($where);
|
|
|
|
87
|
+ }elseif (is_numeric($where)) {
|
|
|
|
88
|
+ $where = dbWhere(['id' => $where]);
|
|
|
|
89
|
+ }
|
|
62
|
$num = 0;
|
90
|
$num = 0;
|
|
63
|
foreach ([self::$table,"lists_back",/*"lists_hot"*/] as $table) {
|
91
|
foreach ([self::$table,"lists_back",/*"lists_hot"*/] as $table) {
|
|
64
|
$sql = "select count(*) as `mc` from `".$table."` where ".$where;
|
92
|
$sql = "select count(*) as `mc` from `".$table."` where ".$where;
|