php - 如何在 laravel eloquent 中使用 substr?

标签 php laravel laravel-5.3 eloquent

我使用 Laravel 5.3

我的laravel Eloquent 是这样的:

$query = User::where('year', '=', (string)$object->year)               
             ->where(\DB::raw('substr(code, 1, 3)'), '=', 511)
             ->get();

我尝试了这样的方法,但没有成功

如何解决?

最佳答案

您忘记在“=”符号后面加上逗号。尝试这个 。

   $query = User::where('year', '=', (string)$object->year)               
           ->where(\DB::raw('substr(code, 1, 3)'), '=' , 511)
           ->get();

关于php - 如何在 laravel eloquent 中使用 substr?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43772915/

相关文章:

jquery - 单击提交表单之前确认对话框

php - Laravel 5.3 - 更改重置密码的身份验证路由

mysql - 拉拉维尔 5.3 : Auto Incrementing Unsigned TINYINT

php - Wordpress 访客登录重定向查看帖子

php - 每个语句 VS 的 PDO 异常。一次交易?

laravel - 以一种形式从laravel nova中的关系添加字段文本

php - 如何将静态参数从路由传递到 Controller - Laravel 5

php - 无法显示 Laravel 数据透视表中的所有记录

php - 通过php调用存储过程时出现奇怪的错误

php - 找不到类 'GuzzleHttp\HandlerStack'