return self::find() ->where(["is_del" => 0, "status" => 1]) ->andWhere('CONCAT(",", `user_category_id`, ",") REGEXP ",('. implode('|', $categoryIds) .'),"') ->orderBy("weight DESC") ->one();
$categoryIds是一个数组,要查询表中以逗号分割的数据是否命中该数组中的任何一个元素
return self::find() ->where(["is_del" => 0, "status" => 1]) ->andWhere('CONCAT(",", `user_category_id`, ",") REGEXP ",('. implode('|', $categoryIds) .'),"') ->orderBy("weight DESC") ->one();
$categoryIds是一个数组,要查询表中以逗号分割的数据是否命中该数组中的任何一个元素