我想实现不区分大小写的搜索以下是我的搜索代码
/*get the title to search*/
$newsTitle=Input::get('srach_newsTitle')?Input::get('srach_newsTitle'):'';
$query = DB::table('news');
if( strlen($newsTitle) )
{
$query->whereRaw('LOWERCASE(`newsTitle`) LIKE ? ',[trim(strtolower($newsTitle)).'%']);
}
Run Code Online (Sandbox Code Playgroud)
但它的功能LOWERCASE未在我的项目中定义以下是错误消息
Connection.php第729行中的QueryException:SQLSTATE [42000]:语法错误或访问冲突:1305功能cpr-laravel.LOWERCASE不存在(SQL:选择count(*)作为聚合,news其中LOWERCASE(newsTitle)LIKE test%)
什么是错的我在做什么?plz帮助
我正在使用laravel 5.2,我想获得所选的雄辩模型的所有列(属性)名称,有没有办法做到这一点?
以下是我在控制器方法中的代码
if($request->method=="edit")
{
/*we are in edit mode details of given news ID should be attached*/
$curNews=News::find($request->newsID);
if($curNews==null)return back()->withErrors(["Unable to Edit News:No Data Found For Given News ID"]);
foreach((array)$curNews->attributes as $key=>$val)
{
$data[$key]=$val;
}
}
return view('adminarea.news.news-addedit',$data);
Run Code Online (Sandbox Code Playgroud) 我有一种形式,当验证失败时我在控制器中进行验证,我通过使用$ myValidator-> errors()返回错误的Messagebag对象而收到错误,但我只希望错误消息作为字符串数组?