我刚买了一个由Laravel和AngularJS构建的脚本(来自codecanyon),现在,当我试图获取" DB :: raw"从SQL(在后端显示一个表)它给我一个错误:
SQLSTATE [42S22]:未找到列:1054未知列' pushes.title' 在'字段列表' (SQL:选择pushes.title,pushes.created_at ....
我能理解错误,没有" pushes.title"在sql表中,看起来所有js对象都没有转换为值,例如" pushes.title"应该是" title"在数据库中,等等。
以下是发送get命令的函数:
public function getDataReport($ filters = array(),$ orders = array()){
$pushes = \Push::select(\DB::raw(" pushes.title, pushes.created_at, pushes.id as pushes_id, pushes.message, pushes.notify_trigger, pushes_to_locations.id as pushes_to_locations_id, pushes_to_locations.location_id, pushes_to_locations.status, locations.lat, locations.address_formated, locations.lng, locations.radius")); $pushes->join('pushes_to_locations','pushes.id','=','pushes_to_locations.pushes_id'); $pushes->join('locations','locations.id','=','pushes_to_locations.location_id'); if(!empty($filters['status'])){ $pushes->whereRaw("(status = ".$filters['status'].")"); } if(!empty($filters['text'])){ $pushes->where("title",'like',"%".$filters['text']."%"); $pushes->orWhere("message",'like',"%".$filters['text']."%"); } $noSort = true; foreach($orders as $col => $orderValue) { if(empty($orderValue)) { continue; }; $noSort = false; $pushes->orderBy($col,$orderValue); } if(($noSort)){ //$orderColumns['order_date'] ='DESC'; $pushes->orderBy('pushes.created_at','desc'); } //echo $apps->toSql(); return $pushes->paginate(20); } }
我在这里缺少什么?我应该安装其他东西吗?
以下是后端说明:
http://ec2-54-179-166-43.ap-southeast-1.compute.amazonaws.com/geofencing/public/backend-guide
(其余部分完全适合我,所以我认为大多数安装都很好)
提前致谢!!
叶兰。
答案 0 :(得分:0)
好的,希望你会比我更快,问题只是我的数据库前缀,由于某种原因,这段代码忽略了我的db前缀,这就是为什么它找不到它,我添加了前缀和一切现在很好。
无论如何,谢谢!