如何使用mid()进行Laravel查询

时间:2019-03-01 22:07:23

标签: php laravel model

8个项目 现在一切正常,但我有问题 在mysql中,我可以运行

hiddenimports=['scipy._lib.messagestream']

我可以在laravel关系中做这样的事情吗 就像我有hiddenimports=['scipy._lib.messagestream', 'scipy'] 表,每个用户都有select * from table where mid(column_name,1,4) = 5 我的意思是我可以做这样的事情

user

ect 谢谢

1 个答案:

答案 0 :(得分:2)

您可以尝试使用whereRaw()函数,即:

User::getVoucherRelation()->whereRaw("mid(created_at,1,4) = $value")->get();
Model_name::Relation()->whereRaw("mid(column_name,1,6) = $value")->get();

您可以在此处查看功能:https://laravel.com/docs/5.7/queries#raw-expressions

相关问题