当前位置:首页>python>Python Web开发:Pydantic进阶

Python Web开发:Pydantic进阶

  • 2026-06-28 11:51:06
Python Web开发:Pydantic进阶
副标题

: 90%的人不知道,Pydantic v2的性能比v1快10倍

痛点:为什么你的数据验证代码总是很繁琐?

2025年某项目有100+数据模型,每个都要写一堆验证逻辑。问题出在哪?工程师没有使用Pydantic的高级特性。

真相

:Pydantic v2用Rust重写,性能提升10倍,功能更强大。

特性v1v2提升
性能1x10x10倍
类型检查基础完整更准确
序列化5-10倍
异步支持新增

一、Pydantic v2基础

1.1 安装与升级

# 安装Pydantic v2

pip install pydantic>=2.0

检查版本

python -c "import pydantic; print(pydantic.__version__)"

1.2 基础模型

from pydantic import BaseModel, Field

class User(BaseModel):

id: int

username: str = Field(..., min_length=3, max_length=50)

email: str

age: int = Field(..., gt=0, lt=150)

is_active: bool = True

class Config:

from_attributes = True # v2中用model_config替代

v2使用model_config

class UserV2(BaseModel):

model_config = ConfigDict(from_attributes=True)

id: int

username: str

email: str

1.3 数据验证

from pydantic import BaseModel, Field, field_validator, model_validator

from typing import Annotated

from datetime import datetime

class Product(BaseModel):

name: str = Field(..., min_length=1, max_length=100)

price: Annotated[float, Field(gt=0)]

quantity: int = Field(ge=0)

category: str

@field_validator('name')

@classmethod

def validate_name(cls, v: str) -> str:

if not v.strip():

raise ValueError('名称不能为空')

return v.strip().title()

@field_validator('price')

@classmethod

def validate_price(cls, v: float) -> float:

return round(v, 2)

@model_validator(mode='after')

def validate_stock(self):

if self.price > 1000 and self.quantity > 100:

raise ValueError('高价商品库存不能过多')

return self

二、字段类型

2.1 基础类型

from pydantic import BaseModel

from typing import Any

class Types(BaseModel):

# 基础类型

integer: int

float_num: float

string: str

boolean: bool

# 可空类型

optional_int: int | None = None

# 默认值

default_str: str = "default"

default_list: list[int] = [1, 2, 3]

2.2 容器类型

from pydantic import BaseModel

from typing import List, Dict, Set, Tuple

class Collections(BaseModel):

# 列表

items: List[str]

# 字典

metadata: Dict[str, Any]

# 集合(自动去重)

tags: Set[str]

# 元组

coordinates: Tuple[float, float]

# 可变长度

numbers: list[int]

2.3 联合类型

from pydantic import BaseModel

from typing import Union

class Flexible(BaseModel):

# 联合类型

value: Union[int, str, float]

# Python 3.10+语法

value_v2: int | str | float

# 可选联合

optional: int | None = None

三、高级验证

3.1 模式验证

from pydantic import BaseModel, Field, field_validator

import re

class User(BaseModel):

username: str = Field(..., pattern=r'^[a-zA-Z0-9_]{3,20}$')

phone: str = Field(..., pattern=r'^1[3-9]\d{9}$')

email: str = Field(..., pattern=r'^[\w\.-]+@[\w\.-]+\.\w+$')

@field_validator('username')

@classmethod

def validate_username(cls, v: str) -> str:

if v.lower() in ['admin', 'root', 'system']:

raise ValueError('用户名不能是保留字')

return v

3.2 自定义验证器

from pydantic import BaseModel, field_validator, model_validator

from datetime import datetime

class Event(BaseModel):

name: str

start_time: datetime

end_time: datetime

max_attendees: int = 100

@field_validator('start_time', 'end_time')

@classmethod

def validate_datetime(cls, v: datetime) -> datetime:

if v < datetime.now():

raise ValueError('时间不能是过去')

return v

@model_validator(mode='after')

def validate_time_range(self):

if self.end_time <= self.start_time:

raise ValueError('结束时间必须晚于开始时间')

return self

3.3 条件验证

from pydantic import BaseModel, Field, field_validator

from typing import Optional

class Payment(BaseModel):

amount: float

method: str

card_number: Optional[str] = None

paypal_email: Optional[str] = None

@field_validator('card_number')

@classmethod

def validate_card(cls, v: Optional[str], info) -> Optional[str]:

if info.data.get('method') == 'card' and not v:

raise ValueError('信用卡支付需要卡号')

return v

@field_validator('paypal_email')

@classmethod

def validate_paypal(cls, v: Optional[str], info) -> Optional[str]:

if info.data.get('method') == 'paypal' and not v:

raise ValueError('PayPal支付需要邮箱')

return v

四、嵌套模型

4.1 基础嵌套

from pydantic import BaseModel

class Address(BaseModel):

street: str

city: str

zip_code: str

country: str = "China"

class User(BaseModel):

id: int

name: str

address: Address

user = User(

id=1,

name="Alice",

address={"street": "123 Main St", "city": "Beijing", "zip_code": "100000"}

)

print(user.address.city) # Beijing

4.2 递归模型

from pydantic import BaseModel

from typing import Optional, List

class TreeNode(BaseModel):

value: int

children: Optional[List['TreeNode']] = None

使用字符串前向引用

TreeNode.model_rebuild()

tree = TreeNode(

value=1,

children=[

TreeNode(value=2),

TreeNode(value=3, children=[TreeNode(value=4)])

]

)

4.3 模型继承

from pydantic import BaseModel

class UserBase(BaseModel):

username: str

email: str

class UserCreate(UserBase):

password: str

class User(UserBase):

id: int

is_active: bool = True

class UserOut(User):

# 排除字段

model_config = {'exclude': {'password'}}

五、序列化

5.1 基础序列化

from pydantic import BaseModel

class User(BaseModel):

id: int

username: str

email: str

user = User(id=1, username="alice", email="alice@example.com")

转为字典

data = user.model_dump()

转为JSON

json_str = user.model_dump_json()

自定义序列化

data = user.model_dump(by_alias=True)

5.2 序列化配置

from pydantic import BaseModel, Field, ConfigDict

from datetime import datetime

class Event(BaseModel):

model_config = ConfigDict(

from_attributes=True,

populate_by_name=True,

str_strip_whitespace=True

)

id: int

name: str

start_time: datetime

# 自定义序列化

def model_dump(self, **kwargs):

dump = super().model_dump(**kwargs)

dump['start_time'] = self.start_time.isoformat()

return dump

5.3 排除字段

from pydantic import BaseModel, Field

class User(BaseModel):

id: int

username: str

password: str = Field(..., exclude=True) # 总是排除

email: str

user = User(id=1, username="alice", password="secret", email="a@e.com")

排除特定字段

data = user.model_dump(exclude={'password'})

data = user.model_dump(exclude={'id', 'password'})

条件排除

data = user.model_dump(exclude_unset=True) # 排除未设置的字段

六、数据转换

6.1 类型转换

from pydantic import BaseModel

class Config(BaseModel):

port: int # 自动转换

timeout: float

enabled: bool

config = Config(port="8080", timeout="30.5", enabled="true")

print(config.port) # 8080 (int)

print(config.timeout) # 30.5 (float)

print(config.enabled) # True (bool)

6.2 自定义类型

from pydantic import BaseModel, field_validator

from datetime import datetime

class Timestamp(BaseModel):

created_at: datetime

@field_validator('created_at', mode='before')

@classmethod

def parse_timestamp(cls, v) -> datetime:

if isinstance(v, str):

return datetime.fromisoformat(v)

if isinstance(v, (int, float)):

return datetime.fromtimestamp(v)

return v

使用

ts = Timestamp(created_at="2026-05-26T10:00:00")

ts2 = Timestamp(created_at=1716688800)

6.3 数据清洗

from pydantic import BaseModel, field_validator

class User(BaseModel):

username: str

email: str

@field_validator('username', 'email', mode='before')

@classmethod

def strip_whitespace(cls, v: str) -> str:

return v.strip() if isinstance(v, str) else v

@field_validator('email')

@classmethod

def lowercase_email(cls, v: str) -> str:

return v.lower()

user = User(username=" Alice ", email=" ALICE@EXAMPLE.COM ")

print(user.username) # Alice

print(user.email) # alice@example.com

七、FastAPI集成

7.1 请求体验证

from fastapi import FastAPI

from pydantic import BaseModel, Field

app = FastAPI()

class ItemCreate(BaseModel):

name: str = Field(..., min_length=1, max_length=50)

price: float = Field(..., gt=0)

description: str | None = Field(None, max_length=500)

tags: list[str] = Field(default_factory=list)

@app.post("/items/")

async def create_item(item: ItemCreate):

return item

7.2 响应模型

from fastapi import FastAPI

from pydantic import BaseModel, SecretStr

class UserIn(BaseModel):

username: str

password: SecretStr

email: str

class UserOut(BaseModel):

username: str

email: str

@app.post("/users/", response_model=UserOut)

async def create_user(user: UserIn):

# password不会被返回

return user

7.3 查询参数验证

from fastapi import FastAPI, Query

from typing import Annotated

app = FastAPI()

@app.get("/items/")

async def read_items(

q: Annotated[str | None, Query(min_length=3)] = None,

skip: Annotated[int, Query(ge=0)] = 0,

limit: Annotated[int, Query(ge=1, le=100)] = 100

):

return {"q": q, "skip": skip, "limit": limit}

八、性能优化

8.1 模型缓存

from pydantic import BaseModel

import time

class Data(BaseModel):

id: int

name: str

value: float

验证耗时

start = time.time()

for _ in range(10000):

Data(id=1, name="test", value=1.5)

print(f"v2耗时: {time.time() - start:.3f}s")

v1对比(如果安装了)

from pydantic.v1 import BaseModel as BaseModelV1

class DataV1(BaseModelV1):

id: int

name: str

value: float

8.2 序列化优化

from pydantic import BaseModel

import json

class LargeData(BaseModel):

id: int

name: str

items: list[dict]

metadata: dict

data = LargeData(

id=1,

name="test",

items=[{"id": i, "name": f"item{i}"} for i in range(100)],

metadata={"key": "value"}

)

快速序列化

json_str = data.model_dump_json()

排除大字段

json_str = data.model_dump_json(exclude={'items'})

九、实战案例

9.1 API请求/响应模型

from pydantic import BaseModel, Field, EmailStr

from typing import Optional

from datetime import datetime

class UserBase(BaseModel):

email: EmailStr

username: str = Field(..., min_length=3, max_length=50)

class UserCreate(UserBase):

password: str = Field(..., min_length=8)

class UserUpdate(BaseModel):

email: Optional[EmailStr] = None

username: Optional[str] = Field(None, min_length=3, max_length=50)

is_active: Optional[bool] = None

class User(UserBase):

id: int

is_active: bool = True

created_at: datetime

model_config = {'from_attributes': True}

class ItemBase(BaseModel):

name: str

price: float = Field(..., gt=0)

description: Optional[str] = None

class ItemCreate(ItemBase):

pass

class Item(ItemBase):

id: int

owner_id: int

created_at: datetime

model_config = {'from_attributes': True}

9.2 分页响应

from pydantic import BaseModel

from typing import Generic, TypeVar, List

T = TypeVar('T')

class Pagination(BaseModel):

page: int

page_size: int

total: int

total_pages: int

class PaginatedResponse(BaseModel, Generic[T]):

data: List[T]

pagination: Pagination

@classmethod

def from_list(cls, data: list[T], page: int, page_size: int, total: int):

total_pages = (total + page_size - 1) // page_size

return cls(

data=data,

pagination=Pagination(

page=page,

page_size=page_size,

total=total,

total_pages=total_pages

)

)

使用

response = PaginatedResponse.from_list(

data=[{"id": 1}, {"id": 2}],

page=1,

page_size=10,

total=25

)

常见坑自查清单

现象自查方法修复方案
v1/v2混用导入错误检查import统一用v2
ConfigDict缺失属性错误检查model_config用ConfigDict
前向引用NameError检查递归模型用字符串或rebuild
类型不匹配验证错误检查类型注解添加正确类型

结语

关键洞察

  • v2性能提升10倍
  • 用model_config替代Config
  • 支持前向引用和递归模型
  • FastAPI深度集成

互动

  1. 1.你升级到Pydantic v2了吗?
  2. 2.v2的性能提升明显吗?
  3. 3.用过哪些高级验证特性?
版本: V1.0 | 2026-05-26 | Python Web开发系列

📚 推荐阅读

📝 摘要:今天深入学习静态代码分析技术,这是安全审计的核心技能。从 Python AST 模块到检测模式设计,收获满满!

发布于 202603

01-Python 环境搭建与第一个脚本

发布于 202603

【优化】Python代码优化与调试技巧

发布于 202603

KEYWORDS

IL, Python, python, 字符串, 列表

💡 如果你觉得这篇文章有帮助,请点个在看,分享给更多需要的人!

📝 关注我,获取更多实用干货~

🤝 有问题欢迎评论区留言交流!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-02 23:25:36 HTTP/2.0 GET : https://f.mffb.com.cn/a/499243.html
  2. 运行时间 : 0.114309s [ 吞吐率:8.75req/s ] 内存消耗:4,513.82kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=39d143855e12656f8516f7a35271e18d
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000520s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000629s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.006097s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000321s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000611s ]
  6. SELECT * FROM `set` [ RunTime:0.000214s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000578s ]
  8. SELECT * FROM `article` WHERE `id` = 499243 LIMIT 1 [ RunTime:0.009163s ]
  9. UPDATE `article` SET `lasttime` = 1783005937 WHERE `id` = 499243 [ RunTime:0.010907s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000279s ]
  11. SELECT * FROM `article` WHERE `id` < 499243 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000495s ]
  12. SELECT * FROM `article` WHERE `id` > 499243 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000639s ]
  13. SELECT * FROM `article` WHERE `id` < 499243 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.003000s ]
  14. SELECT * FROM `article` WHERE `id` < 499243 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.008506s ]
  15. SELECT * FROM `article` WHERE `id` < 499243 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002939s ]
0.115923s