2014-10-05 76 views
1

我添加jenssegers Laravel-MongoDB的包到我的Laravel 4.2項目,並有一個問題。也許可以幫助我。我不能在select或get方法中使用DB :: raw。我需要更改選擇列的名稱並將列添加到一列中,但Laravel返回給我一個錯誤。 我嘗試做這樣的事情:生選擇使用jenssegers Laravel-MongoDB的

$arr = StudentMark::join('students', 'students.id','=','student_marks.student_id') 
     ->select(array('student_marks.id',DB::raw('CONCAT(students.name, " ", 
students.surname, " (", students.index,") ") AS student')))->get(); 

但Laravel返回我一個錯誤:

{"error":{"type":"ErrorException","message":"Illegal offset type","file":".....vendor\\jenssegers\\mongodb\\src\\Jenssegers\\Mongodb\\Query\\Builder.php","line":240}} 

任何人可以幫助我嗎?

回答

0

我用select的列,並concating列結果的foreach做,然後返回到客戶端,這解決了我的問題。 :)