Issue
Here's my code. The database name is socapa.
class Student extends Model
{
...
public static function rsStuds(
$varSession_rsStuds,
$varCampus_rsStuds,
$varProgram_rsStuds,
$varSeason_rsStuds,
$startRow_rsStuds,
$maxRows_rsStuds) {
return Student::select(
'contacts.FirstName',
'contacts.LastName',
'contacts.ContactID',
'students.StudentID',
'registrations.CourseID',
'registrations.RegDate',
'contacts.City',
'contacts.State',
'contacts.Country',
'campuses.CampusName',
'programs.ProgramName',
'courses.SessionID',
'courses.CourseName',
'courses.Season',
'students.StudentID',
'programs.ProgramID',
'sessions.SessionID',
'sessions.SessionName',
'programs.ProgramName')
->join('registrations', 'students.StudentID', '=', 'registrations.StudentID')
->join('contacts', 'contacts.ContactID', '=', 'students.StudentContactID')
->join('courses', 'courses.CourseID','=', 'registrations.CourseID')
->join('campuses', 'campuses.CampusID', '=', 'courses.CampusID')
->join('programs', 'programs.ProgramID', '=', 'courses.ProgramID')
->join('sessions', 'sessions.SessionID', '=', 'courses.SessionID')
->where('courses.SessionID', 'LIKE', "%".$varSession_rsStuds."%")
->where('courses.CampusID', 'LIKE', "%".$varCampus_rsStuds."%")
->where('courses.ProgramID', 'LIKE', "%".$varProgram_rsStuds."%")
->where('courses.Season', '=', ''.$varSeason_rsStuds)
->groupBy('courses.ProgramID')
->orderBy('contacts.LastName')
->skip(''.$startRow_rsStuds)
->take(''.$maxRows_rsStuds)->get();
}
...
}
When I run the project, the error following bellow, appears.
Illuminate\Database\QueryException SQLSTATE[42000]: Syntax error or access violation: 1055 'socapa.contacts.FirstName' isn't in GROUP BY (SQL: select
contacts
.FirstName
,contacts
.LastName
,contacts
.ContactID
,students
.StudentID
,registrations
.CourseID
,registrations
.RegDate
,contacts
.City
,contacts
.State
,contacts
.Country
,campuses
.CampusName
,programs
.ProgramName
,courses
.SessionID
,courses
.CourseName
,courses
.Season
,students
.StudentID
,programs
.ProgramID
,sessions
.SessionID
,sessions
.SessionName
,programs
.ProgramName
fromstudents
inner joinregistrations
onstudents
.StudentID
=registrations
.StudentID
inner joincontacts
oncontacts
.ContactID
=students
.StudentContactID
inner joincourses
oncourses
.CourseID
=registrations
.CourseID
inner joincampuses
oncampuses
.CampusID
=courses
.CampusID
inner joinprograms
onprograms
.ProgramID
=courses
.ProgramID
inner joinsessions
onsessions
.SessionID
=courses
.SessionID
wherecourses
.SessionID
LIKE %1% andcourses
.CampusID
LIKE %1% andcourses
.ProgramID
LIKE %1% andcourses
.Season
= -1 group bycourses
.ProgramID
order bycontacts
.LastName
asc limit 50 offset 0)
Solution
Go to the config
folder and open database.php
find mysql
and change
'strict' => false,
Answered By - Tharuka Dananjaya Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.