public static function listData($key){
return self::when($key,function ($query) use ($key){
$query->where('title',"like","%$key%");
})->get();
}
// $key为搜索的关键字
此篇博客介绍了如何在PHP中使用自定义函数listData,通过关键字对数据库中的title字段进行模糊匹配查询,展示了SQL查询的技巧。
public static function listData($key){
return self::when($key,function ($query) use ($key){
$query->where('title',"like","%$key%");
})->get();
}
// $key为搜索的关键字

被折叠的 条评论
为什么被折叠?