Created
December 1, 2018 17:50
-
-
Save koras/647f1dd948c0847603d720d727a12c93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SQLSTATE[HY093]: Invalid parameter number | |
// (SQL: select (select `user`.`id` from `user` | |
// where `user`.`id` in (2013, 2015) limit 1) as ff | |
// from `user` as `tmp_user` | |
// where `tmp_user`.`year` in (2016, 2017, 2018, ?, ?)) | |
$arrayUser = [5,6]; | |
$arrayYear = [2013,2015,2016,2017,2018]; | |
$subSelect = DB::table('user') | |
->select('user.id') | |
->wherein('user.id',$arrayUser) | |
->limit(1) | |
->toSql(); | |
// var_dump($subSelect); | |
$res = DB::table('user as tmp_user') | |
->select( DB::raw('('.$subSelect.') as ff') | |
) | |
->wherein('tmp_user.year',$arrayYear) | |
->get(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment