mardi 6 décembre 2016

Add custom field during select mysql in laravel query

I have this query in laravel 5.2

$obj_custom_stdy_data = QstCustomStudyData::where('student_id', $this->data_user['student_id'])
                    ->select($list_id . ' as list_id ', 'chapter_id', 'subject_id', 'subject_code_id')
                    ->get()
                    ->toArray();

Well I have a fixed value $list_id got from top code. Actually I want to add new field during query selection as list_id. However I got error for such that method.

When I tried in mysql IDE for example:

SELECT (1+2) as total, c.* FROM users

Then the result is no wrong at all.

Is that anyway to write in query builder for laravel instead of raw style?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire