Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLSTATE[42000]: Syntax error or access violation #53

Closed
alejandri opened this issue Feb 19, 2015 · 3 comments
Closed

SQLSTATE[42000]: Syntax error or access violation #53

alejandri opened this issue Feb 19, 2015 · 3 comments

Comments

@alejandri
Copy link

In home www/ Starter Site show this: (but i can acces to admin panel correctly)

QueryException in Connection.php line 614:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '{tbpfx}filename from photo WHERE album_cover=1 and ${tbpfx}photo.photo_album_id=' at line 1 (SQL: select photo_album.id, photo_album.name, photo_album.description, photo_album.folderid, (select ${tbpfx}filename from photo WHERE album_cover=1 and ${tbpfx}photo.photo_album_id=${tbpfx}photo_album.id) AS album_image, (select ${tbpfx}filename from photo WHERE ${tbpfx}photo.photo_album_id=${tbpfx}photo_album.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first from photo_album limit 8)

@ricardopaiva
Copy link

Alejandri, you can see the changes suggested by idangozlan. Check the only pull request that's active.

@alejandri
Copy link
Author

Thanks. I solved changed in HomeController this:

public function index()
{
$news = $this->news->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
$sliders = Photo::join('photo_album', 'photo_album.id','=','photo.photo_album_id')
->where('photo.slider',1)
->orderBy('photo.position', 'DESC')
->orderBy('photo.created_at', 'DESC')
->select('photo.filename','photo.name','photo.description','photo_album.folderid')->get();

        $photoalbums = PhotoAlbum::select(array('photo_album.id', 'photo_album.name', 'photo_album.description',
                'photo_album.folderid',
                DB::raw('(select filename from photo WHERE album_cover=1 and photo.photo_album_id=photo_album.id) AS album_image'),
                DB::raw('(select filename from photo WHERE photo.photo_album_id=photo_album.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();

        $videoalbums = VideoAlbum::select(array('video_album.id', 'video_album.name', 'video_album.description',
                'video_album.folderid',
                DB::raw('(select youtube from video as v WHERE album_cover=1 and v.video_album_id=video_album.id) AS album_image'),
                DB::raw('(select youtube from video WHERE video.video_album_id=video_album.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();

        return view('site.home.index',compact('news','sliders','videoalbums','photoalbums'));
}

@stojankukrika
Copy link
Collaborator

TNX for help! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants