当前位置:网站首页>学习路之PHP--TP5.0使用中文当别名,报“不支持的数据表达式”
学习路之PHP--TP5.0使用中文当别名,报“不支持的数据表达式”
2022-07-25 10:20:00 【hopetomorrow】

代码如下:
//简化
echo '<br/>';
$id=1;
var_dump(
Db::select(
function ($query)use($id){
$query->table('tp5_user')
->field(['user_id'=>'编号','user_name'=>'姓名']) //别名 不支持的数据表达式:编号
//->field(['user_id as 编号','user_name as 姓名']) //别名
->where([
'user_id'=>['>',$id]
]);
}
)
);解决方法一:找到目录 \thinkphp\library\think\db\builder\Mysql.php

将正则表达式改为以下内容
if ($strict && !preg_match('/^[\w\.\*\x7f-\xff]+$/', $key)) {
throw new Exception('not support data:' . $key);
}解决方法二:
->field(['user_id as 编号','user_name as 姓名']) //别名
边栏推荐
- HCIP(12)
- 一文读懂小程序的生命周期和路由跳转
- mysql事务是什么
- Flask框架——flask-caching缓存
- Learn NLP with Transformer (Chapter 8)
- Esp8266 uses drv8833 drive board to drive N20 motor
- AI technology stack is too huge! Wu Enda gives career planning: lifelong learning
- The practice of asynchronous servlet in image service
- Hcip experiment (01)
- 基于cornerstone.js的dicom医学影像查看浏览功能
猜你喜欢

企业实践开源的动机

Learn NLP with Transformer (Chapter 6)

Ue4.26 source code version black screen problem of client operation when learning Wan independent server

The most comprehensive UE4 file operation in history, including opening, reading, writing, adding, deleting, modifying and checking

HCIP (01)

Reinforcement Learning 强化学习(四)

HCIA experiment (09)

AI系统前沿动态第43期:OneFlow v0.8.0正式发布;GPU发现人脑连接;AI博士生在线众筹研究主题

UE4 framework introduction

从开源的视角,解析SAP经典ERP “三十年不用变”的架构设计
随机推荐
HCIA实验(10)NAT
UE4 framework introduction
Learn NLP with Transformer (Chapter 8)
【IJCAI 2022】参数高效的大模型稀疏训练方法,大幅减少稀疏训练所需资源
最详细的mysql索引解析(文末附赠思维导图)
HDD Hangzhou station full experience
API supplement of JDBC
HCIP(11)
Flask framework - session and cookies
Learn NLP with Transformer (Chapter 4)
Flask framework - Message flash
What is MySQL transaction
Understand the life cycle and route jump of small programs
哥廷根大学提出CLIPSeg:一个使用文本和图像prompt能同时作三个分割任务的模型
UE4.26源码版学习广域网独立服务器时遇到的客户端运行黑屏问题
[domain generalization] 2022 IJCAI domain generalization tutorial Report
Flame framework - Flame WTF form: file upload, verification code
Flask framework - flask WTF form: data validation, CSRF protection
100W了!
I, AI doctoral student, online crowdfunding research topic