Pgsql error: You might need to add explicit type casts

前端 未结 2 584
鱼传尺愫
鱼传尺愫 2021-02-12 18:04

My website is just working fine til i deployed it to heroku and the problem is heroku uses pgsql and I\'m using mysql and laravel framework.

my query is



        
相关标签:
2条回答
  • 2021-02-12 18:16

    The problem is here:

    $q->where('vaccine_id','ILIKE','%' . $vaccine_id)
    

    looks like vaccine_id is integer, and you can not use operator ILIKE to integer. Try just '='

    If you want to use LIKE, ILIKE or other text operator you must cast your data to text. In SQL it must looks like:

    WHERE "vaccine_id"::text ILIKE val
    

    instead

    WHERE "vaccine_id" ILIKE val
    
    0 讨论(0)
  • 2021-02-12 18:30

    You could do this:

    $q->where('cast(vaccine_id AS VARCHAR)','LIKE','%' . $vaccine_id)
    

    OR

    $q->where('cast(vaccine_id AS TEXT)','LIKE','%' . $vaccine_id)
    
    0 讨论(0)
提交回复
热议问题