Search code examples
phppostgresqllaravelhstore

Select where HSTORE value is $value Laravel


Using the query builder to try and select rows where a value in the HSTORE key $type is present.

My Where Statement:

->where("meta_data_fields->'$type'", 'like', '%'.$query.'%')

Not sure what I'm doing wrong. I get this error:

Undefined column: 7 ERROR: column "meta_data_fields->'Entity::hstore'" does      not exist

Any ideas?


Solution

  • So here's what worked in my situation with Laravel.

    $result = \DB::select(\DB::raw("SELECT hstore_fields, id from table where lower(hstore_fields->'$type') like lower('%$query%')"));