|
...
|
...
|
@@ -41,7 +41,11 @@ class listsSql { |
|
|
|
* @time 2023/3/17 16:24
|
|
|
|
*/
|
|
|
|
public static function first($db,string $where,$filed='*', $throw=false) {
|
|
|
|
|
|
|
|
if(is_array($where)){
|
|
|
|
$where = dbWhere($where);
|
|
|
|
}elseif (is_numeric($where)) {
|
|
|
|
$where = dbWhere(['id' => $where]);
|
|
|
|
}
|
|
|
|
foreach ([self::$table,"lists_back","lists_hot"] as $table) {
|
|
|
|
$sql = "select {$filed} from `".$table."` where ".$where.' limit 1';
|
|
|
|
if($throw){
|
|
...
|
...
|
@@ -58,7 +62,31 @@ class listsSql { |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function maxUid($db,string $where){
|
|
|
|
if(is_array($where)){
|
|
|
|
$where = dbWhere($where);
|
|
|
|
}elseif (is_numeric($where)) {
|
|
|
|
$where = dbWhere(['id' => $where]);
|
|
|
|
}
|
|
|
|
$uid = 0;
|
|
|
|
foreach ([self::$table,"lists_back",/*"lists_hot"*/] as $table) {
|
|
|
|
$sql = "select max(`uid`) as `mc` from `".$table."` where ".$where;
|
|
|
|
$data = $db->value($sql);
|
|
|
|
if($data) {
|
|
|
|
$uid = max($uid, $data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $uid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function count($db,string $where){
|
|
|
|
if(is_array($where)){
|
|
|
|
$where = dbWhere($where);
|
|
|
|
}elseif (is_numeric($where)) {
|
|
|
|
$where = dbWhere(['id' => $where]);
|
|
|
|
}
|
|
|
|
$num = 0;
|
|
|
|
foreach ([self::$table,"lists_back",/*"lists_hot"*/] as $table) {
|
|
|
|
$sql = "select count(*) as `mc` from `".$table."` where ".$where;
|
...
|
...
|
|