2015-06-21 47 views
0

我剛剛購買了一個由Laravel和AngularJS構建的腳本(來自codecanyon),現在,當我試圖從SQL獲取「DB :: raw」(在後端顯示一個表)它給我一個錯誤:laravel + AngularJs:不能執行SQL命令

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pushes.title' in 'field list' (SQL: select pushes.title, pushes.created_at ....

我能理解錯誤,沒有在SQL表「pushes.title」,它看起來像所有的JS對象不轉換爲值,例如「pushes.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

錯誤消息說''pushes'表中不存在'title'列。什麼是混亂? –

+0

它是存在的,錯誤說:「pushes.title」是不存在的,而事實上它不是.. –

+0

對不起,您的評論是沒有意義的。 –

回答

0

好吧,希望你會更快然後我的問題是隻有我的數據庫前綴,從某種原因,這種代碼忽略我的數據庫前綴,這就是爲什麼它找不到它,我已經添加前綴,一切都現在好了。

謝謝你!