framework: Sql error when Model::where()->first()

Hi,

  • Laravel Version: 5.6.20
  • PHP Version: 7.2
  • Database Driver & Version: mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper

Description:

Migration :

Schema::create('google_places', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('place_id');
});

Here is the code : GooglePlace::where('place_id', $place_id)->first();

Error produced by Eloquent Model :

SQLSTATE[HY000]: General error:  (SQL: select * from `google_places` where `place_id` = ChIJ_bzdbKTazRIR4-0ippvrlZo limit 1)

I have tested the sql statement on mysql cli and added quotes around the place_id:

select * from `google_places` where `place_id` = 'ChIJ_bzdbKTazRIR4-0ippvrlZo' limit 1

and the query works. How i can add quotes with an Eloquent Model?

Thanks for reply.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (8 by maintainers)

Most upvoted comments

I meant on HHVM (if you want to keep using it).