Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在laravel中使用正则表达式而不是链接或where语句_Php_Laravel_Eloquent - Fatal编程技术网

Php 在laravel中使用正则表达式而不是链接或where语句

Php 在laravel中使用正则表达式而不是链接或where语句,php,laravel,eloquent,Php,Laravel,Eloquent,我正在使用eloquent向我的数据库编写一个查询。我链接了几个orWhere语句,我想一定有一个正则表达式的方法。我试图返回所有不以字母数字开头的技能字段。 这是我到目前为止所拥有的 $skills = $skills->where('skill', 'LIKE', " %")->orWhere('skill', 'LIKE', ",%")->orWhere('skill', 'LIKE', "-%") ->orWhere('skill'

我正在使用eloquent向我的数据库编写一个查询。我链接了几个orWhere语句,我想一定有一个正则表达式的方法。我试图返回所有不以字母数字开头的技能字段。 这是我到目前为止所拥有的

$skills = $skills->where('skill', 'LIKE', " %")->orWhere('skill', 'LIKE', ",%")->orWhere('skill', 'LIKE', "-%")
                ->orWhere('skill', 'LIKE', ":%");

与其写出所有可能的非字母数字字符,还不如用whereRaw。像这样的事情应该让你开始:

$skills->whereRaw("skill REGEXP '^[^0-9a-zA-Z]'");