Laravel-5'LIKE'同等学历(口才) [英] Laravel-5 'LIKE' equivalent (Eloquent)

查看:33
本文介绍了Laravel-5'LIKE'同等学历(口才)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码通过Laravel 5从数据库中提取一些结果.

I'm using the below code to pull some results from the database with Laravel 5.

BookingDates::where('email', Input::get('email'))->orWhere('name', 'like', Input::get('name'))->get()

但是,orWhereLike似乎与任何结果都不匹配.根据MySQL语句,该代码产生了什么?

However, the orWhereLike doesn't seem to be matching any results. What does that code produce in terms of MySQL statements?

我正在尝试实现以下目标:

I'm trying to achieve something like the following:

select * from booking_dates where email='my@email.com' or name like '%John%'

推荐答案

如果要查看数据库中正在运行的内容,请使用dd(DB::getQueryLog())查看正在运行的查询.

If you want to see what is run in the database use dd(DB::getQueryLog()) to see what queries were run.

尝试一下

BookingDates::where('email', Input::get('email'))
    ->orWhere('name', 'like', '%' . Input::get('name') . '%')->get();

这篇关于Laravel-5'LIKE'同等学历(口才)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆