php - 从laravel中的一句话中取一个词?
问题描述
$text="Samsung Galaxy s21 ";
$product= Product::Select('*')->where('name', 'like', "%{$text}%")->get();
我如何获得Galaxy
相关产品表格$product
解决方案
$product= Product::where('name', 'like', '%' . $text . '%')->get();
或者
$product= Product::where('name', 'like', "%$text%")->get();
你可以这样做。从这个线程得到它, Laravel-5 'LIKE' 等效(雄辩)
推荐阅读
- android - 应用关闭时获取位置更新 Android
- python - 调用具有动态对象名 pyqt5 的函数
- ios - 在 UICollectionView 中拖动行和列
- robotframework - 在远程主机上的命名空间内运行守护程序。(机器人框架)
- python - 我为脚本多次工作做错了吗?
- java - JPA。过滤字段 Set<> 包含特定值的实体
- python - 在 python 中计算重复项。为什么我们应该只取 set 而不是 list 或 dict?
- bash - 让 gitlab 工作不等待“脚本”部分的任何返回
- python - 在数据python中用nans计算3个数组的加权平均值
- javascript - 方法测量模拟期间代理未使用的时间