Skip to content

Sql error when Model::where()->first() #24085

@loic-lopez

Description

@loic-lopez

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions